Estou tentando utilizar o --findRelatedTests
para rodar testes no pre-commit utilizando o lint-staged, mas o seguinte erro sempre acontece
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.
Eu adicionei o script no package.json
"test": "jest --no-cache --verbose",
"test:watch": "yarn test --watch",
"test:staged": "yarn test --findRelatedTests --bail",
E meu lint-staged.config.js
está dessa maneira
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',
],
}