Joe Beams
Joe Beams

Reputation: 195

Jest Deleting snapshots when updating single test

Im having a weird issue where Jest is deleting all snapshots when I am attempting to update a single test.

if I have a directory:

07/03/2018  11:05 AM           131,285 p-Error.ts.snap
07/03/2018  11:05 AM            75,741 p-Lot.ts.snap
06/29/2018  03:39 PM           134,879 p-Split.ts.snap

and I run:

npm test -- -i -u -t="p-Split"

Here is the console output:

PASS  src/__tests__/p-Split.ts (279.875s)r\openvrpaths.vrpath

 FAIL  src/__tests__/p-Error.ts
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at node_modules/jest-cli/build/test_scheduler.js:245:22

 FAIL  src/__tests__/p-Lot.ts
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at node_modules/jest-cli/build/test_scheduler.js:245:22

and the directory now contains:

06/29/2018  03:40 PM           134,879 p-Split.ts.snap

Thanks, Joe

Upvotes: 5

Views: 12905

Answers (1)

Herman Starikov
Herman Starikov

Reputation: 2764

Snapshots are deleted because of the -u flag, which automatically removes unused/obsolete snapshots.

Why would you want to keep those snapshots, if you removed everything from the test files p-Error and p-Lot? If you removed p-Error and p-Lot test cases by accident, bring them back.

Upvotes: 8

Related Questions