Snapshot feature will modify existing snapshots without passing `--update-snapshots` flag
See original GitHub issueDescription
The results with snapshots are inconsistent when ran multiple times with no code changes. I’ve provided a repository with an example below.
Upon cloning the repo and running npm test
it will pass the tests but leave the snapshots modified (See output of 2nd pass below). If you run tests again, it will throw an error (See 3rd pass output below).
For what it’s worth, I was using the master
branch after the snapshot feature first landed and had no issues. It seems like the bug was introduced when the magic assert feature was introduced. I even tried deleting the snapshot folder and getting a fresh run, but it still produces the same results.
Error Message & Stack Trace
# 2nd pass
> ava
4 passed
~/Projects/ava-snapshot-issue master*
# 3rd pass
> ava
3 passed
1 failed
renders custom width
test.js:9
8:
9: t.snapshot(tree)
10: }
Error: Unexpected token m in JSON at position 28
Test.snapshot (test.js:9:5)
npm ERR! Test failed. See above for more details.
Config
Copy the relevant section from package.json
:
{
"ava": {
"babel": "inherit",
"require": "babel-register"
}
}
Command-Line Arguments
Copy your npm build scripts or the ava
command used:
npm test
Relevant Links
See reproducable repo here: https://github.com/wyze/ava-snapshot-issue
Environment
Node.js v7.1.0 darwin 16.1.0 npm 4.0.3 AVA 0.18
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:15 (9 by maintainers)
Thank you for a detailed bug report, I just reproduced it and looking into it.
Actually, we should not save snapshot if we are running within CI server. E.g. snapshots should be tested against data committed to source control.