question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snapshot feature will modify existing snapshots without passing `--update-snapshots` flag

See original GitHub issue

Description

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:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
vadimdemedescommented, Feb 2, 2017

Thank you for a detailed bug report, I just reproduced it and looking into it.

1reaction
CrOrccommented, Mar 21, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >
Snapshot | Guide - Vitest
When using snapshot, Vitest will take a snapshot of the given value, ... the --update or -u flag in the CLI to make...
Read more >
Jest React - New snapshot was not written. The update flag ...
New snapshot was not written. The update flag must be explicitly passed to write a new snapshot. This is likely because this test...
Read more >
Snapshot Testing - Jest - w3resource
A typical snapshot test case for a mobile app will render a UI ... if the two snapshots do not match: either when...
Read more >
Snapshot Testing · Jest - GitHub Pages
A typical snapshot test case for a mobile app renders a UI component, takes a ... The test will fail if the two...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found