mutant-cafe 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +66 -2
- package/dist/bin.js +1272 -0
- package/dist/bin.js.map +7 -0
- package/package.json +35 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joel Hooks
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mutant.cafe
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Mutation testing for [Effect](https://effect.website) TypeScript. mutant.cafe reads your types, breaks your functions in ways that still type-check, runs the tests related to each break, and lists the breaks your tests miss.
|
|
6
|
+
|
|
7
|
+
It is inspired by [cargo-mutants](https://mutants.rs) by Martin Pool ([source](https://github.com/sourcefrog/cargo-mutants), MIT). The core idea, replacing a function body with a plausible value of its return type and reporting what the tests don't notice, comes from cargo-mutants, and so does the operator experience: a baseline run first, a scratch copy of your tree, per-mutant timeouts, `--in-diff`, and a `mutants.out` directory of results. mutant.cafe ports those ideas to Effect; it shares no code with cargo-mutants.
|
|
8
|
+
|
|
9
|
+
## What it adds for Effect
|
|
10
|
+
|
|
11
|
+
An `Effect<A, E, R>` declares its failures in `E`. For each tagged error in `E`, mutant.cafe makes a mutant that swallows that error and succeeds instead. If your tests still pass, no test drives that failure path.
|
|
12
|
+
|
|
13
|
+
Other mutants, all chosen from the checker's view of the return type:
|
|
14
|
+
|
|
15
|
+
- `Effect.succeed(value)` for plausible values of `A`, `Effect.fail` of each tag, `Effect.die`, and `Effect.never` behind a short timeout
|
|
16
|
+
- `Option.none()` and `Option.some(value)`
|
|
17
|
+
- `Stream.empty`, a one-element stream, and a failing stream
|
|
18
|
+
- a `Layer` that fails at build
|
|
19
|
+
- flipped booleans and cycled literal unions
|
|
20
|
+
|
|
21
|
+
## Use it
|
|
22
|
+
|
|
23
|
+
Needs Node 24 or later, a `tsconfig.json`, and a vitest suite that passes.
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install -D mutant-cafe
|
|
27
|
+
npx mutant-cafe --list # preview the mutants
|
|
28
|
+
npx mutant-cafe --jobs 4 # test them
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Run it from the package whose tests you want to check. In a monorepo that resolves workspace packages through built output, build the package's dependencies first.
|
|
32
|
+
|
|
33
|
+
| Flag | Meaning |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| `--list` | print the mutants and exit |
|
|
36
|
+
| `--in-diff <file>` | only mutants on lines a unified diff adds or changes |
|
|
37
|
+
| `--file <glob>`, `--exclude <glob>` | choose source files (repeatable) |
|
|
38
|
+
| `--jobs <n>` | scratch copies tested in parallel |
|
|
39
|
+
| `--timeout <s>` | per-mutant test timeout; default 5× the baseline run, at least 20 s |
|
|
40
|
+
| `--timeout-multiplier <x>`, `--minimum-test-timeout <s>` | tune that default |
|
|
41
|
+
| `--output <dir>` | results directory, default `mutants.out` |
|
|
42
|
+
| `--tsconfig <path>` | default `tsconfig.json` |
|
|
43
|
+
|
|
44
|
+
Results land in `mutants.out/`: `missed.txt`, `caught.txt`, `timeout.txt`, `unviable.txt`, a diff and a log per mutant, and `outcomes.json`. Add `mutants.out*` to `.gitignore`. Your source tree is never edited: each mutant runs in a scratch copy.
|
|
45
|
+
|
|
46
|
+
Exit codes: 0 every viable mutant was caught, 1 usage error, 2 some mutants were missed, 3 some timed out, 4 the baseline tests fail, 5 the `--in-diff` diff doesn't match the tree, 6 the diff can't be parsed, 70 internal error.
|
|
47
|
+
|
|
48
|
+
## Outcomes
|
|
49
|
+
|
|
50
|
+
| Outcome | Meaning |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| caught | a related test failed |
|
|
53
|
+
| missed | every related test passed |
|
|
54
|
+
| unviable | the mutant does not type-check |
|
|
55
|
+
| timeout | the tests ran past the per-mutant timeout |
|
|
56
|
+
|
|
57
|
+
## Prior art
|
|
58
|
+
|
|
59
|
+
[StrykerJS](https://stryker-mutator.io) and its Effect 4 fork [stryker-js-effect](https://github.com/systemfsoftware/stryker-js-effect) mutate syntax (operators, literals, blocks, and some Effect concurrency faults) and use the type checker to discard mutants that don't compile. mutant.cafe uses the checker to generate mutants from types instead. Use both if you like; they find different gaps.
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT
|
|
64
|
+
|
|
65
|
+
## Package build
|
|
66
|
+
|
|
67
|
+
esbuild-wasm 0.28.2 bundles workspace code into Node 24 ESM with source maps and external runtime dependencies, without native install scripts.
|