Skip to content

Snapshot feature will modify existing snapshots without passing --update-snapshots flag #1218

@wyze

Description

@wyze

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcurrent functionality does not work as desired

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions