snap-shot-core
Advanced tools
Comparing version 1.6.1 to 1.7.0
{ | ||
"name": "snap-shot-core", | ||
"description": "Save / load named snapshots, useful for tests", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/bahmutov/snap-shot-core/issues", |
@@ -141,2 +141,25 @@ # snap-shot-core | ||
## Testing in watch mode | ||
In case you execute your tests in watch mode and you notice the snapshots are always new-created for the same set of tests, then you need to restore the counters per file. | ||
tape example: | ||
```js | ||
//foo.test.js | ||
const test = require('tape'); | ||
const snapShot = require('snap-shot-core') | ||
test.onFinish(snapShot.restore) | ||
test('one test', function (t) { | ||
t.plan(1) | ||
snapShot({ | ||
what: 1, | ||
file: __filename, | ||
specName: 'one test' | ||
}) | ||
}) | ||
``` | ||
### Small print | ||
@@ -143,0 +166,0 @@ |
@@ -28,3 +28,3 @@ 'use strict' | ||
// keeps track how many "snapshot" calls were there per test | ||
const snapshotsPerTest = {} | ||
var snapshotsPerTest = {} | ||
@@ -34,2 +34,6 @@ const formKey = (specName, oneIndex) => | ||
function restore () { | ||
snapshotsPerTest = {} | ||
} | ||
function findStoredValue ({file, specName, index = 1, ext, opts = {}}) { | ||
@@ -174,2 +178,4 @@ la(is.unemptyString(file), 'missing file to find spec for', file) | ||
snapShotCore.restore = restore | ||
module.exports = snapShotCore |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22797
441
210