TypeScript: a test that imports its module as '.' or '..' is linked, not copied, so its mutants are reported SURVIVED
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python, typescript
- Domain
- testing-qa
Research direction
Start in workers.py and inspect the import-specifier pattern and _candidates, which the issue says already resolves '.' and '..' to an index file. Run the provided Vitest reproduction before and after the change, then run mutator's own suite. Done means the reproduction reports the mutant as KILLED and the suite still passes.
Written by the indexing model from the issue text.
Description
Thanks for mutator. It found real gaps in our TypeScript suite. While using it I hit one case where it reports mutants as surviving when the tests do kill them.
workers.py copies a module into the worker when it imports the mutated file through a relative path, so Node loads the mutant. The specifier pattern needs at least one character after the dot:
r"""(?:from|import|require)\s*\(?\s*['"](\.[^'"]+)['"]"""
So '.' and '..' (a directory's index) never match. A test that imports its module that way stays a symlink, Node resolves it to the project, and the test runs against the original file.
Repro (mutator a5a0cb8, macOS 27.0.1, Node 22.23.4, Vitest 3.2.4, no Vitest config)
src/calc/index.ts:
export function big(x: number): boolean {
return x > 10;
}
src/calc/index.test.ts:
import { expect, it } from 'vitest';
import { big } from '.';
it('eleven is big', () => expect(big(11)).toBe(true));
it('ten is not big', () => expect(big(10)).toBe(false));
$ ./node_modules/.bin/vitest run
Tests 2 passed (2)
$ mutator --no-coverage --test-command "./node_modules/.bin/vitest run" src/calc/index.ts
SURVIVED src/calc/index.ts:2 > -> >=
big calc.index 0 1 0 1 0.0%
Applying the same mutant by hand (x >= 10) gives 1 failed | 1 passed, so it should be KILLED.
Possible fix
Let the dot stand alone. _candidates already resolves . and .. to index.<ext>:
- r"""(?:from|import|require)\s*\(?\s*['"](\.[^'"]+)['"]""",
+ r"""(?:from|import|require)\s*\(?\s*['"](\.[^'"]*)['"]""",
With that change the repro reports KILLED (100%), and mutator's own suite still passes (76 passed). In our project, one file went from 0 of 25 mutants killed to 19 of 25, and a hand-applied spot check agreed.
Related: #19 (same cause, reached through a linked directory or a path alias).
- Dominant language
- Python
- Stars
- 112
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from unclebob/mutator
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 2 days
-
test_git_status_keeps_real_names_and_fails_closed fails when git output is translatedPossibly taken @bennibyx claimed this 14 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 83/100
unclebob/mutator#24 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 2 days
-
Workers leave out source in a directory named build, out, dist, target or coverage, so every mutant is reported KILLEDPossibly taken @lohmag claimed this 17 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
Legacy backup recovery overwrites newer source and deletes the backup without conflict detectionOpen
Difficulty 3/5 Half a day Newbie friendliness 35/100
Maintainers usually reply within 2 days
All issues in unclebob/mutator
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pierreaubert/gpui-toolkit#114 ·
Maintainers usually reply within 1 day
-
intake mcp-intake needs-human-review priority:high type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Ikalus1988/MisakaNet#4903 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
FinanceFlash/unvibecode#819 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day