eugene-manuilov / jest-runner-groups

A custom runner that allows to tag test files and run groups of tests with Jest.
MIT License
128 stars 14 forks source link

My console coverage stats are gone when I use jest-runner-groups #5

Closed fex80 closed 4 years ago

fex80 commented 4 years ago

Hey, thanks for making this great package! I just tried it out and it works great --- but my console coverage stats are not working correctly when I use jest-runner-groups.

Here's my output when before using the "groups" runner:

$ npm run test
[...]
-----------------|---------|----------|---------|---------|-------------------
File             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------------|---------|----------|---------|---------|-------------------
All files        |   97.37 |     61.9 |     100 |   97.14 |
 src             |     100 |       50 |     100 |     100 |
  db.ts          |     100 |       50 |     100 |     100 | 13,14,26,27
 src/entity      |     100 |      100 |     100 |     100 |
  Recording.ts   |     100 |      100 |     100 |     100 |
  Session.ts     |     100 |      100 |     100 |     100 |
  TimeOfDay.ts   |     100 |      100 |     100 |     100 |
 src/radiotools  |   93.94 |    69.23 |     100 |   93.94 |
  radiostatus.ts |   93.94 |    69.23 |     100 |   93.94 | 47,48
-----------------|---------|----------|---------|---------|-------------------

After I add runner: "groups", to my jest.config, the output is like this:

$npm run test
[...]
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------

I love the group runner, but I don't want to loose my instant feedback on coverage.

This is my jest config.

module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
 // runner: "groups",
  roots: [
    '<rootDir>/src'
  ],
  testMatch: [
    '**/__tests__/**/*.+(ts|tsx|js)',
    '**/?(*.)+(spec|test).+(ts|tsx|js)'
  ],
  transform: {
    '^.+\\.(ts|tsx)$': 'ts-jest'
  },
  collectCoverage: true,
 // coverageReporters: ['html'],
  globals: {
    'ts-jest': {
      tsConfig: {
        importHelpers: true,
        downlevelIteration: true,
        esModuleInterop: true,
      }
    }
  }
};

and this the relevant part from the package.json:

 "test": "npx jest --coverage --passWithNoTests",
 "unit": "npx jest --coverage --passWithNoTests --group=unit",
 "integration": "npx jest --coverage --passWithNoTests --group=integration",

Is this by design, or can I set it up in a different way to keep my stats visible? Thanks!

eugene-manuilov commented 4 years ago

Hi @fex80

looks like it is a bug, I'll try to fix it asap.

rmclaughlin-nelnet commented 4 years ago

Looks like an incompatibility between this package and the latest version of jest. I get coverage when I use version 24.9.0 of jest

eugene-manuilov commented 4 years ago

@rmclaughlin-nelnet you are 100% right... why didn't I check it at the beginning? :man_facepalming: I had hard times 3 days ago trying to figure out what was going on :)

I'll update the dependencies and publish a new version.

eugene-manuilov commented 4 years ago

Ok, I have just published a new version 1.1.1 which contains the latest jest dependencies. The code coverage should work properly now.

eugene-manuilov commented 4 years ago

Thank you, @rmclaughlin-nelnet!

jwmcconnell commented 4 years ago

Hey, wanted to let you know I just had some tests break while using the latest update your package. I've pinned my version to 1.1.0 and everything went back to normal but at 1.1.1 I get this output:

TypeError: this._config.extraGlobals is not iterable

      at Runtime.constructInjectedModuleParameters (node_modules/jest-runner-groups/node_modules/jest-runtime/build/index.js:1426:23)
rmclaughlin-nelnet commented 4 years ago

Just a suggestion, you may want to make jest a peer dependency, or a dev dependency in your package, then users can choose their own version of jest. You also wont have to update your package every time a new version of jest is released. You could do something like

"peerDependencies": { "jest": ">= 24.9.0" }

eugene-manuilov commented 4 years ago

Hm... @jwmcconnell which version of jest do you have in your package.json?

jwmcconnell commented 4 years ago

24.9.0

eugene-manuilov commented 4 years ago

Ok, that's because jest-runner-groups uses jest-runner@^25.1.0 which doesn't work properly with jest before version 25.0.0. Even don't know what to do now. One option is to publish jest-runner-groups with version 24.9.0 which works with jest 24.9.0 and version 25.1.0 which works with jest 25.1.0. Another option is to publish jest-runner-groups v1.1.2 with peerDependencies that declares the minimum version of jest supported by this runner. :thinking:

jwmcconnell commented 4 years ago

Hey, wanted to let you know we upgraded our jest to version 25.1.0 so everything is working with 1.1.1 of your package on our end.

afinegan commented 4 years ago

Until the release version of Jest is 25 I cant use 1.1.1, (I use ts-jest which isn't compatible with 25 yet, it opens a whole can of worms), so I am stuck at 1.1.0

eugene-manuilov commented 4 years ago

Ok, i have just released the new version: 2.0.1 - it declares jest-runner and jest-docblock as peer dependencies. So, it should work with jest@24.9.0 and higher now. Closing this thread.