I am working on a Next.js project in Typescript and am currently using the SWC compiler. As a result, I'm using @swc/jest for my tests. All my tests are passing, but the coverage report always comes back empty. Here's what my jest.config.js
looks like:
module.exports = {
'roots': ['<rootDir>/../src'],
'moduleDirectories': ['node_modules', 'src'],
'setupFilesAfterEnv': ['<rootDir>/setup-tests.js'],
'coverageDirectory': '<rootDir>/../coverage',
'verbose': true,
'collectCoverage': true,
'transform': {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
'jsc': {
target: 'es2021',
},
'sourceMaps': true,
},
],
},
'collectCoverageFrom': [
'<rootDir>/../src/**.{ts,js,tsx,jsx}',
'!**/node_modules/**',
],
}
My file structure looks like:
.
├── coverage
├── jest
│ ├── jest.config.js
│ ├── setup-tests.js
├── src/
├── tsconfig.json
The output looks like this:
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
Test Suites: 11 passed, 11 total
Tests: 25 passed, 25 total
Snapshots: 0 total
Time: 1.307 s
Ran all test suites.
I created an issue on @swc/jest, but I'm not sure if this is an issue with them or something else so I figured I'd ask here too.