Skip to content

Jest detects linux .snap package file as obsolete snapshot #8922

@nahuelarjonadev

Description

@nahuelarjonadev

Current 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

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