Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some tests not skipped in incremental mode. #3909

Closed
mkizka opened this issue Dec 18, 2022 · 3 comments · Fixed by #3910
Closed

Some tests not skipped in incremental mode. #3909

mkizka opened this issue Dec 18, 2022 · 3 comments · Fixed by #3910
Labels
🐛 Bug Something isn't working

Comments

@mkizka
Copy link
Contributor

mkizka commented Dec 18, 2022

Summary
Some tests run each time in incremental mode. I expect the tests to be skipped on the second run.

The tests like:

test.each`
  x    | y    | expected
  ${1} | ${1} | ${2}
  ${1} | ${2} | ${3}
  ${2} | ${2} | ${4}
`("add($x, $y) = $expected", ({ x, y, expected }) => {
  expect(add(x, y)).toBe(expected);
});

When such a test exists, stryker shows Tests: 1 files changed (+2 -0) even though I haven't changed any tests.

The cause seems to be that each test has the same start position. This code removes tests with the same start position.

Reproduction steps:

$ git clone https://github.com/mkizka/stryker-js-jest-each
$ cd stryker-js-jest-each
$ yarn
$ yarn stryker run --incremental
$ yarn stryker run --incremental

Expected behavior:
All tests are skipped the second time.

Actual behavior:
Some tests run the second time.

I'm using google translate, so I'm sorry if there are strange parts in the sentences.

Stryker config

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "_comment": "This config was generated using 'stryker init'. Please take a look at: https://stryker-mutator.io/docs/stryker-js/configuration/ for more information.",
  "packageManager": "yarn",
  "reporters": ["html", "clear-text", "progress"],
  "testRunner": "jest",
  "testRunner_comment": "More information about the jest plugin can be found here: https://stryker-mutator.io/docs/stryker-js/jest-runner",
  "coverageAnalysis": "perTest"
}

Stryker environment

+-- @stryker-mutator/core@6.3.0
+-- @stryker-mutator/jest-runner@6.3.0
+-- jest@29.3.1

Test runner environment

$ jest

Your Environment

software version(s)
node v18.12.1
npm 9.2.0
Operating System Ubuntu(WSL2)

Add stryker.log
stryker.log (second run in reproduction steps)

@mkizka mkizka added the 🐛 Bug Something isn't working label Dec 18, 2022
@nicojs
Copy link
Member

nicojs commented Dec 18, 2022

Hi @mkizka, thanks for opening this issue with detailed reproduction steps!

This is a bug, but not in the line of code you're referring to the problem is here. I forgot to account for more than 1 test starting on the same line when they are the last test in the file 🤦‍♀️.

A current workaround is to add a final test under the tests with the same start position:

const { add } = require("../add");

test.each`
  x    | y    | expected
  ${1} | ${1} | ${2}
  ${1} | ${2} | ${3}
  ${2} | ${2} | ${4}
`("add($x, $y) = $expected", ({ x, y, expected }) => {
  expect(add(x, y)).toBe(expected);
});

+ test('one final test', () => {});

@mkizka
Copy link
Contributor Author

mkizka commented Dec 18, 2022

Thank you for your answer and quick fix!

@nicojs
Copy link
Member

nicojs commented Dec 18, 2022

Sure thing ☺. I had some time, so you reported it just at the right moment 🤗

I also fixed the bug and released the fix in version 6.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants