Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Coverage not being collected from file called "payload.ts" #951

Open
jahilldev opened this issue Jun 21, 2022 · 0 comments
Open

Coverage not being collected from file called "payload.ts" #951

jahilldev opened this issue Jun 21, 2022 · 0 comments

Comments

@jahilldev
Copy link

This is a very strange one, and I've exhausted known possibilites, at least that I can think of.

I have the following coverage config for jest:

// jest.config.js

module.exports = {
  /*[...]*/
  collectCoverage: true,
  collectCoverageFrom: ['<rootDir>/src/**/*.{ts,tsx}'],
  coverageDirectory: '<rootDir>/tests/coverage',
  coveragePathIgnorePatterns: ['/node_modules/', '(.*).d.ts'],
};

All of my test suites are running correctly, but one file in particular isn't collecting coverage.

It seems mad, but I feel like it's related to the filename (?!), payload.ts.

I have three files in my ./src directory:

  • payload.ts
  • utility.ts
  • index.ts

However, when I run Jest I get the following output:

$ jest --no-cache
PASS  tests/payload.test.ts
PASS  tests/utility.test.ts
------------|---------|----------|---------|---------|-------------------
File        | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files   |   73.68 |    70.37 |   57.14 |   72.97 |
 index.ts   |       0 |      100 |     100 |       0 | 7-8
 utility.ts |   77.77 |    70.37 |   57.14 |   77.14 | 8-9,53-68
------------|---------|----------|---------|---------|-------------------

Test Suites: 2 passed, 2 total
Tests:       16 passed, 16 total
Snapshots:   0 total
Time:        8.816 s
Ran all test suites.
✨  Done in 10.42s.

I've tried removing / re-creating the payload.ts file, thinking it might be filesystem related, but no luck. I've also tried the --no-cache flag that I've seen mentioned elsewhere, but again, no luck.

If I rename the file to something like payload_s.ts, it works as expected, generating coverage.

I'll try and put a re-production together sometime soon, but wanted to post this before I forgot / just renamed the file and called it a day.

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant