vscode-jest icon indicating copy to clipboard operation
vscode-jest copied to clipboard

Incorrectly counting tests

Open PindaPixel opened this issue 2 years ago • 0 comments

Environment

  1. vscode-jest version: 4.6.0
  2. node -v: 16.x
  3. npm -v or yarn --version: yarn v1.22.18
  4. npm ls jest or npm ls react-scripts (if you haven’t ejected):
@vue/[email protected]
  ├─┬ [email protected]
  │ └── [email protected] deduped
  └── [email protected]
  1. your vscode-jest settings if customized:
    • jest.jestCommandLine? yarn test ("test": "vue-cli-service test:unit" in package.json)
    • jest.autoRun: off
  2. Operating system: macOS 12.5 (Apple Silicon)

Prerequisite

  • are you able to run jest test from the command line? Yes
  • how do you run your tests from the command line? (for example: npm run test or node_modules/.bin/jest) yarn test

Steps to Reproduce

  • Vue 2 project with @vue/cli-plugin-unit-jest@5.
  • "testMatch": ["**/__tests__/**/*.[jt]s?(x)"]
  • A single test:
// __tests__/test.js
describe('<Unit>', () => {
    it('<behaviour>', () => {
        expect(1).toEqual(1);
    })
});

Expected Behavior

When tests are discovered but not run, it should say 0/{test count} tests passed. When tests are run, it should say {passed tests}/{test count}

Actual Behavior

When tests are discovered but not run, it says 0/0 tests passed no matter the amount of tests present in the UI. When the tests are run, it says {passed tests + passed suites}/{test count + suite count} tests passed in the UI.

However, when a test fails, the passed count is displayed correctly but the test count is still one too many.

In the CLI it does display the correct count:

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total

It is likely just adding up suites + tests, but this seems like unexpected behavior to me. Edit: this is the case, it counts a suite as a test in the counter.


The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR...

PindaPixel avatar Jul 26 '22 13:07 PindaPixel