Using Jest in bitbucket pipelines, it doesn't find the tests and hence failed with the following error :
+ npx jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /opt/atlassian/pipelines/agent/build
12 files checked.
testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 2 matches
testPathIgnorePatterns: /node_modules/, /build/ - 0 matches
testRegex: - 0 matches
Pattern: - 0 matches
Locally my tests run fine.
Project structure :
.
├── build
│ ├── coverage
│ └── js
└── src
├── account
│ ├── account.ts
│ └── account.test.ts
├── index.ts
└── index.test.ts
jest.config.js
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
"^.+\\.(t|j)sx?$": "ts-jest",
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
coverageDirectory: "build/coverage",
testPathIgnorePatterns: ["/node_modules/", "/build/"],
};
Tests are launched using following npm script
"test": "jest --coverage",
Is it normal for Jest not to run the test it finds with testMatch
?
- Tried to switch from
testMatch
totestRegex
without success - Tried to add the path to src in the launch script (
npx jest ./src
)