--findRelatedTests does not work

Asked

Viewed 16 times

0

I’m trying to use the --findRelatedTests to run pre-commit tests using lint-staged, but the following error always happens

The --findRelatedTests option requires file paths to be specified. Example Usage: jest --findRelatedTests . /src/source.js . /src/index.js. error Command failed with Exit code 1.

I added the script to package.json

    "test": "jest --no-cache --verbose",
    "test:watch": "yarn test --watch",
    "test:staged": "yarn test --findRelatedTests --bail",

And mine lint-staged.config.js is that way

module.exports = {
  // Lint then format JavaScript files
  '**/*.js': filenames => [
    `yarn eslint --fix ${filenames.join(' ')}`,
    `yarn prettier --write ${filenames.join(' ')}`,
  ],

  // Format MarkDown and JSON
  '**/*.(md|json)': filenames => `yarn prettier --write ${filenames.join(' ')}`,

  // Run all tests
  '**/*.test.js': () => 'yarn test:staged',
}

jest.config.js

module.exports = {
  preset: 'react-native',
  setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'],
  transformIgnorePatterns: [
    'node_modules/(?!(jest-)?@?react-native|@react-native-community|@react-navigation|@sentry)',
  ],
  testPathIgnorePatterns: ['/node_modules', '/android', '/ios', '/ci'],
  collectCoverage: true,
  collectCoverageFrom: [
    'src/**/*.js',
    '!src/**/*.test.js',
  ],
  coverageReporters: ['lcov'],
  setupFiles: [
    './src/main/config/tests/mock.js',
  ],
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.