New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

snap-shot-core

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snap-shot-core - npm Package Compare versions

Comparing version 1.7.5 to 1.8.0

2

package.json
{
"name": "snap-shot-core",
"description": "Save / load named snapshots, useful for tests",
"version": "1.7.5",
"version": "1.8.0",
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/bahmutov/snap-shot-core/issues",

@@ -165,2 +165,12 @@ # snap-shot-core

You can restore / reset a counter for a particular test
```js
const snapShot = require('snap-shot-core')
snapShot.restore({
file: __filename,
specName: 'this test'
})
```
### Small print

@@ -167,0 +177,0 @@

@@ -33,4 +33,13 @@ 'use strict'

function restore () {
snapshotsPerTest = {}
function restore (options) {
if (!options) {
debug('restoring all counters')
snapshotsPerTest = {}
} else {
const {file, specName} = options
la(is.unemptyString(file), 'missing file', options)
la(is.unemptyString(specName), 'missing specName', options)
debug('restoring counter for file "%s" test "%s"', file, specName)
delete snapshotsPerTest[specName]
}
}

@@ -119,3 +128,7 @@

const setOrCheckValue = any => {
const index = snapshotIndex({specName, counters: snapshotsPerTest})
const index = snapshotIndex({
counters: snapshotsPerTest,
file: fileParameter,
specName
})
la(is.positive(index), 'invalid snapshot index', index,

@@ -122,0 +135,0 @@ 'for\n', specName, '\ncounters', snapshotsPerTest)

@@ -6,5 +6,9 @@ 'use strict'

function snapshotIndex ({counters, specName}) {
// TODO: we should also consider the file spec name + test name
// not just spec name (which is test name here)
function snapshotIndex ({counters, file, specName}) {
la(is.object(counters), 'expected counters', counters)
la(is.unemptyString(specName), 'expected specName', specName)
la(is.unemptyString(file), 'missing filename', file)
if (!(specName in counters)) {

@@ -11,0 +15,0 @@ counters[specName] = 1

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc