Skip to content

[jest-snapshot] Custom Snapshot Directories confuse the Obsolete Snapshot Logger #7257

@fbartho

Description

@fbartho

🐛 Bug Report

When using the new snapshot resolver feature: #6143, the "Obsolete" Snapshot checker is deciding that all my snapshots are obsolete after a test run.

To Reproduce

  1. Using a simple project, configure a snapshot resolver to move your snapshot files to a different directory-structure.
  2. Run yarn test notice all your tests pass, and snapshots are in their new location
  3. Notice that it says 45 snapshot files obsolete from 45 test suites.
  4. Run jest -u to remove obsolete snapshots, notice that all your snapshots are gone.

Expected behavior

I would expect that the snapshot files that just got written to wouldn't be considered instantly obsolete.

Speculation: It looks like the custom snapshotResolver isn't invoked when analyzing obsolete snapshots, so Jest doesn't know that these files were actually written to, or something else is weird.

Link to repl or repo (highly encouraged)

I haven't yet figured out how to do Snapshot Testing in repl.it, will upload a repo shortly if I can't find an example.

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  Binaries:
    Node: 10.10.0 - /usr/local/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 6.0.0 - /usr/local/bin/npm
  npmPackages:
    @types/jest: 23.x => 23.3.7 
    jest: ^24.0.0-alpha.1 => 24.0.0-alpha.1 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions