Jest detects linux .snap package file as obsolete snapshot
See original GitHub issueCurrent behavior
when running Jest, it’s detecting a .snap package I built for Linux as an obsolete snapshot, and it’s causing my tests to fail. I tried ignoring the folder with no success.
Part of the test output:
[1] Snapshot Summary
[1] › 1 snapshot file obsolete from 1 test suite. To remove it, run `yarn run test:main -u`.
[1] ↳ • release/kafka-lens_2.0.0_amd64.snap
[1]
[1] Test Suites: 1 skipped, 2 passed, 2 of 3 total
[1] Tests: 2 skipped, 6 passed, 8 total
[1] Snapshots: 1 file obsolete, 1 passed, 1 total
[1] Time: 4.173s
[1] Ran all test suites matching /main/i.
[0] Snapshot Summary
[0] › 1 snapshot file obsolete from 1 test suite. To remove it, run `yarn run test:renderer -u`.
[0] ↳ • release/kafka-lens_2.0.0_amd64.snap
[0]
[0] Test Suites: 10 passed, 10 total
[0] Tests: 37 passed, 37 total
[0] Snapshots: 1 file obsolete, 10 passed, 10 total
[0] Time: 4.171s
[0] Ran all test suites matching /client/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[0] yarn test:renderer exited with code 1
[1] yarn test:main exited with code 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
package.json scripts:
"test": "concurrently \"yarn test:renderer\" \"yarn test:main\"",
"test:renderer": "jest client",
"test:main": "jest main"
Folder Structure
client
|--src
|--components
|--__tests__
|--__snapshots__
|--component.jsx.snap
|--...
main
|--...
release
|--kafka-lens_2.0.0_amd64.snap
|--...
jest.config.js
package.json
jest.config.js
module.exports = {
verbose: true,
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFiles: ['./setupTests.js'],
moduleNameMapper: {
'\\.(css|less|scss)$': '<rootDir>/client/src/app/__mocks__/styleMock.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/client/src/app/__mocks__/assetsTransformer.js',
},
moduleDirectories: ['node_modules'],
modulePaths: ['<rootDir>'],
testPathIgnorePatterns: ['<rootDir>/release/', '<rootDir>/node_modules/'],
};
Expected behavior
Being able to ignore the path to the release folder, so Jest doesn’t try to parse any files inside it as a snapshot
envinfo
System:
OS: Linux 5.0 Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 10.16.2 - ~/.nvm/versions/node/v10.16.2/bin/node
Yarn: 1.17.3 - ~/WebstormProjects/kafka-lens/node_modules/.bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.2/bin/npm
npmPackages:
jest: ^24.1.0 => 24.9.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8 (1 by maintainers)
Top Results From Across the Web
What are obsolete snapshots and snapshot files?
"Obsolete" refers to snapshots or snapshot files, for which no .toMatchSnapshot() exists any more. Snapshots are organised in one file per test ...
Read more >Jest: How to Update Snapshot Tests - In Plain English
Run the Snapshot Test; Change the UI; Rerun the Snapshot Test — Confirm it Fails on the Changes; Update the Snapshot Files ......
Read more >Frontend testing standards and style guidelines - GitLab Docs
We use Jest to write frontend unit and integration tests. Jest tests can be found in /spec/frontend and /ee/spec/frontend in EE. Limitations of...
Read more >Jest - Obsolete snapshots are not detected : WEB-37035
Add jest test with snapshot · Run tests in --watch mode (snapshot will be created) · Rename test - that will create new...
Read more >vscode-jest - Visual Studio Marketplace
View and update snapshots interactively. Help debug jest tests in vscode. Show coverage information in files being tested.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Similar issue – Postgres creates
.snap
files, and so far I’ve found no combination ofroots
,testPathIgnorePatterns
or other settings that will make jest ignore these files if they exist below the project root. These files are reported as obsolete snapshots and fail the jest test. Innocently runningjest -u
deletes the DB files. Bad surprise.What’s needed:
1 – ignore files named
*.snap
unless they are Jest snapshots; don’t show as obsolete; don’t delete via-u
; etc.2 – respect the various path parameters (
testPathIgnorePatterns
,modulePathIgnorePatterns
,roots
, probably others I’m not aware of.3 – provide a big-hammer config option
disableSnapshots
that if set, doesn’t look for or operate on snapshots at allThanks to both! I was trying to find the code which looked for the snap files, but I couldn’t find it on my own. I’ll give it a look and maybe I can think of a solution.
Why don’t just ignore snap files inside
testPathIgnorePatterns
?