@systemfsoftware/stryker-ignorer-in-source-vitest-block 0.1.0 → 0.1.3
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/CHANGELOG.md +18 -0
- package/README.md +24 -50
- package/dist/index.d.ts +6 -9
- package/dist/index.mjs +12 -34
- package/package.json +17 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @systemfsoftware/stryker-ignorer-in-source-vitest-block
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
Build and lint with effect 4.1.0 and @effect/tsgo 0.63.0; the published code is unchanged.
|
|
6
|
+
|
|
7
|
+
## 0.1.2
|
|
8
|
+
|
|
9
|
+
Effect moves to `4.0.0-rc.117`, together with the `@effect/*` packages these libraries use. Projects that install `effect` next to them need the same release.
|
|
10
|
+
|
|
11
|
+
- The TypeScript checker and test-runner workers now bundle their own runtime, so the only modules they load from your project are the TypeScript compiler and your test framework.
|
|
12
|
+
- The test-runner plugin supports the framework's fifth major release.
|
|
13
|
+
- The ignorer interface re-exports the `oxc-parser` 0.150 AST, in which `FormalParameterRest.decorators` is `Array<Decorator>`. Enable the `@effect/language-service` tsgo plugin in every source package's `tsconfig.app.json` and `tsconfig.test.json`, and bump `@effect/tsgo` to `^0.50.0`. This turns on Effect-aware diagnostics during `effect-tsgo` type checking; it changes no runtime behaviour or public API.
|
|
14
|
+
|
|
15
|
+
## 0.1.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Effect moves to `4.0.0-rc.116` (with `@effect/platform-node`, `@effect/platform-node-shared`, `@effect/vitest` and `@effect/opentelemetry` on the same release), the `@systemfsoftware/*` toolchain pins move to their current releases, and `vitest` 5 with `oxc-parser` 0.150 come along. Both worker bundles (`stryker-js-typescript-checker`, `stryker-js-vitest-runner`) now inline their whole runtime rather than resolving `effect`, `@effect/*` and the sibling packages from the host's tree, so a worker runs on its own copy of the effect that built it; the project's `typescript` and `vitest` remain the only imports beside Node builtins. The filter-level `arbitrary.candidate` generators that the thresholds schemas carried are gone: v4 no longer reads them, so thresholds still reject a `low` above `high` and the property tests generate the pair from the schema again. Log calls inside `Effect.catch*` handlers moved to `Effect.tapError`/`Effect.tapCause` at the same level and message. `@systemfsoftware/stryker-ignorer-interface` re-exports the 0.150 AST, where `FormalParameterRest.decorators` is now `Array<Decorator>`.
|
|
20
|
+
|
|
3
21
|
## 0.1.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# @systemfsoftware/stryker-ignorer-in-source-vitest-block
|
|
2
2
|
|
|
3
|
-
](../../../LICENSE)
|
|
4
|
+
[](https://www.npmjs.com/package/@systemfsoftware/stryker-ignorer-in-source-vitest-block)
|
|
5
5
|
|
|
6
|
-
> In-source tests are not production
|
|
6
|
+
> In-source tests are not production behavior. Stop their mutants from dragging your Stryker score below 100%.
|
|
7
7
|
|
|
8
|
-
Your `if (import.meta.vitest)` blocks are stripped before production, so
|
|
8
|
+
Your `if (import.meta.vitest)` blocks are stripped before production, so code executing during mutation testing never reaches them. They sit in reports as false unkillable survivors.
|
|
9
|
+
|
|
10
|
+
This Stryker ignorer recognizes and skips mutants inside `import.meta.vitest` test guards, ensuring 100% mutation testing accuracy.
|
|
9
11
|
|
|
10
12
|
## Install
|
|
11
13
|
|
|
@@ -13,59 +15,31 @@ Your `if (import.meta.vitest)` blocks are stripped before production, so nothing
|
|
|
13
15
|
pnpm add -D @systemfsoftware/stryker-ignorer-in-source-vitest-block
|
|
14
16
|
```
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
## Setup in `stryker.config.ts`
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
| ---------- | --------------------------------------------------------- |
|
|
20
|
-
| `plugins` | `@systemfsoftware/stryker-ignorer-in-source-vitest-block` |
|
|
21
|
-
| `ignorers` | `in-source-vitest-block` |
|
|
20
|
+
Add the package name to `ignorers`. Every ignorer the module exports is then active.
|
|
22
21
|
|
|
23
22
|
```ts
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'@systemfsoftware/stryker-
|
|
29
|
-
|
|
30
|
-
ignorers: ['in-source-vitest-block'],
|
|
31
|
-
}
|
|
23
|
+
import { defineConfig } from '@systemfsoftware/stryker-js/config'
|
|
24
|
+
|
|
25
|
+
export default defineConfig({
|
|
26
|
+
testRunner: {
|
|
27
|
+
plugin: '@systemfsoftware/stryker-js-vitest-runner',
|
|
28
|
+
},
|
|
29
|
+
ignorers: ['@systemfsoftware/stryker-ignorer-in-source-vitest-block'],
|
|
30
|
+
})
|
|
32
31
|
```
|
|
33
32
|
|
|
34
|
-
Mutants
|
|
35
|
-
|
|
36
|
-
> [!WARNING]
|
|
37
|
-
> A name in `ignorers` that no loaded plugin answers is silently skipped — the run proceeds and the mutants stay in your score. Copy the name from the table, not from memory.
|
|
38
|
-
|
|
39
|
-
> [!NOTE]
|
|
40
|
-
> Requires `@systemfsoftware/stryker-js-engine` 4.1.0 or later (the first version whose plugin loader speaks the plain ignorer protocol). The package has no peer dependencies, no Effect dependency at all, and two dependencies — `@systemfsoftware/stryker-ignorer-interface`, whose node types declare the AST shapes the visitors read, and `@systemfsoftware/stryker-ignorer-kit`, which compiles the visitor declaration to the wire contract and verifies it from source snippets.
|
|
41
|
-
|
|
42
|
-
## Migrating from `@systemfsoftware/stryker-plugins`
|
|
43
|
-
|
|
44
|
-
| Before | After |
|
|
45
|
-
| ------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
46
|
-
| `"plugins": ["@systemfsoftware/stryker-plugins"]` | `"plugins": ["@systemfsoftware/stryker-ignorer-in-source-vitest-block"]` |
|
|
47
|
-
| `"ignorers": ["in-source-vitest-block"]` | unchanged |
|
|
48
|
-
|
|
49
|
-
## What it ignores
|
|
50
|
-
|
|
51
|
-
| Guard shape | Example |
|
|
52
|
-
| ---------------------------------------------------------- | ----------------------------------------------- |
|
|
53
|
-
| The bare Vitest flag | `if (import.meta.vitest) { … }` |
|
|
54
|
-
| The flag on either side of a comparison | `if (import.meta.vitest === undefined) { … }` |
|
|
55
|
-
| Any mutant whose ancestors include one of the guards above | the whole guarded block, test fixtures included |
|
|
56
|
-
|
|
57
|
-
## Where the line is
|
|
58
|
-
|
|
59
|
-
The ignored mutants are _unreachable_, not merely believed equivalent: the guard is false under the mutation run, so no test can exercise what is inside it. That is a different claim from a proven-equivalent mutant, and it is why the reason constant says so.
|
|
60
|
-
|
|
61
|
-
- A flag on a different meta property (`import.meta.env`) or on a non-import meta (`require.meta.vitest`) is **not** a guard — its mutants stay live.
|
|
62
|
-
- A bare `import.meta.vitest` expression without an enclosing `if` is **not** a guard.
|
|
63
|
-
- Only the guard shape is recognized; ordinary `if` statements keep every mutant, because their branches are reached in production.
|
|
33
|
+
Mutants inside guarded test blocks are reported as `Ignored`.
|
|
64
34
|
|
|
65
|
-
##
|
|
35
|
+
## What It Ignores
|
|
66
36
|
|
|
67
|
-
|
|
37
|
+
| Guard Shape | Example |
|
|
38
|
+
| ---------------------------------- | ----------------------------------------------------- |
|
|
39
|
+
| Direct Vitest meta property check | `if (import.meta.vitest) { ... }` |
|
|
40
|
+
| Comparison check | `if (import.meta.vitest !== undefined) { ... }` |
|
|
41
|
+
| Enclosed declarations and fixtures | All test suites and utilities nested within the block |
|
|
68
42
|
|
|
69
43
|
## License
|
|
70
44
|
|
|
71
|
-
[Apache
|
|
45
|
+
[Apache-2.0](../../../LICENSE)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { Ignorer } from
|
|
2
|
-
|
|
3
|
-
export declare const IN_SOURCE_TEST_IGNORED: 'inside an `if (import.meta.vitest)` block — test code, not production behaviour';
|
|
4
|
-
|
|
5
|
-
export declare const strykerIgnorers: readonly Ignorer[];
|
|
6
|
-
|
|
7
|
-
export declare const VITEST_META_PROPERTY: 'vitest';
|
|
8
|
-
|
|
9
|
-
export { }
|
|
1
|
+
import { Ignorer } from "@systemfsoftware/stryker-ignorer-interface";
|
|
2
|
+
//#region src/in-source-vitest-block.d.ts
|
|
3
|
+
export declare const IN_SOURCE_TEST_IGNORED: 'inside an `if (import.meta.vitest)` block — test code, not production behaviour';
|
|
4
|
+
export declare const VITEST_META_PROPERTY: 'vitest';
|
|
5
|
+
export declare const strykerIgnorers: readonly Ignorer[];
|
|
6
|
+
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
import { defineIgnorer } from "@systemfsoftware/stryker-ignorer-kit";
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/in-source-vitest-block.ts
|
|
3
3
|
const IN_SOURCE_TEST_IGNORED = "inside an `if (import.meta.vitest)` block — test code, not production behaviour";
|
|
4
4
|
const VITEST_META_PROPERTY = "vitest";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
function propertyIsVitest(node) {
|
|
18
|
-
return isIdentifierNamed(node.property, VITEST_META_PROPERTY);
|
|
19
|
-
}
|
|
20
|
-
function isImportMetaVitestMemberShape(node) {
|
|
21
|
-
return objectIsImportMeta(node) && propertyIsVitest(node);
|
|
22
|
-
}
|
|
23
|
-
function isImportMetaVitestMember(node) {
|
|
24
|
-
return isNonComputedMember(node) && isImportMetaVitestMemberShape(node);
|
|
25
|
-
}
|
|
26
|
-
function operandIsImportMetaVitest(node) {
|
|
27
|
-
return isImportMetaVitestMember(node.left) || isImportMetaVitestMember(node.right);
|
|
28
|
-
}
|
|
29
|
-
function isBinaryGuardTest(node) {
|
|
30
|
-
return node.type === "BinaryExpression" && operandIsImportMetaVitest(node);
|
|
31
|
-
}
|
|
32
|
-
function isGuardTest(node) {
|
|
33
|
-
return isImportMetaVitestMember(node) || isBinaryGuardTest(node);
|
|
34
|
-
}
|
|
35
|
-
function isGuardStatement(node) {
|
|
36
|
-
return node.type === "IfStatement" && isGuardTest(node.test);
|
|
37
|
-
}
|
|
5
|
+
const isIdentifierNamed = (node, name) => node.type === "Identifier" && node.name === name;
|
|
6
|
+
const isNonComputedMember = (node) => node.type === "MemberExpression" && node.computed === false;
|
|
7
|
+
const isImportMeta = (node) => isIdentifierNamed(node.meta, "import") && isIdentifierNamed(node.property, "meta");
|
|
8
|
+
const objectIsImportMeta = (node) => node.object.type === "MetaProperty" && isImportMeta(node.object);
|
|
9
|
+
const propertyIsVitest = (node) => isIdentifierNamed(node.property, VITEST_META_PROPERTY);
|
|
10
|
+
const isImportMetaVitestMemberShape = (node) => objectIsImportMeta(node) && propertyIsVitest(node);
|
|
11
|
+
const isImportMetaVitestMember = (node) => isNonComputedMember(node) && isImportMetaVitestMemberShape(node);
|
|
12
|
+
const operandIsImportMetaVitest = (node) => isImportMetaVitestMember(node.left) || isImportMetaVitestMember(node.right);
|
|
13
|
+
const isBinaryGuardTest = (node) => node.type === "BinaryExpression" && operandIsImportMetaVitest(node);
|
|
14
|
+
const isGuardTest = (node) => isImportMetaVitestMember(node) || isBinaryGuardTest(node);
|
|
15
|
+
const isGuardStatement = (node) => node.type === "IfStatement" && isGuardTest(node.test);
|
|
38
16
|
const strykerIgnorers = [defineIgnorer({
|
|
39
17
|
name: "in-source-vitest-block",
|
|
40
18
|
visitors: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/stryker-ignorer-in-source-vitest-block",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
23
|
"files": [
|
|
24
|
-
"dist"
|
|
24
|
+
"dist",
|
|
25
|
+
"CHANGELOG.md"
|
|
25
26
|
],
|
|
26
27
|
"exports": {
|
|
27
28
|
".": {
|
|
@@ -31,24 +32,25 @@
|
|
|
31
32
|
"./package.json": "./package.json"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@systemfsoftware/stryker-ignorer-interface": "^0.1.
|
|
35
|
-
"@systemfsoftware/stryker-ignorer-kit": "^0.1.
|
|
35
|
+
"@systemfsoftware/stryker-ignorer-interface": "^0.1.3",
|
|
36
|
+
"@systemfsoftware/stryker-ignorer-kit": "^0.1.3"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@effect/tsgo": "^0.
|
|
39
|
+
"@effect/tsgo": "^0.63.0",
|
|
39
40
|
"@microsoft/api-extractor": "^7",
|
|
40
|
-
"@systemfsoftware/arethetypeswrong-cli": "^4",
|
|
41
|
-
"@systemfsoftware/
|
|
41
|
+
"@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
|
|
42
|
+
"@systemfsoftware/oxlint-ignorer-config": "^0.1.3",
|
|
43
|
+
"@systemfsoftware/tsconfig": "^2.0.1",
|
|
44
|
+
"@systemfsoftware/tsdown-config": "^0.1.0",
|
|
45
|
+
"@systemfsoftware/vitest": "^2.0.0",
|
|
46
|
+
"@systemfsoftware/vitest-config": "^0.1.0",
|
|
42
47
|
"@types/node": "^24",
|
|
43
|
-
"@vitest/coverage-v8": "^
|
|
44
|
-
"oxlint": "
|
|
48
|
+
"@vitest/coverage-v8": "^5",
|
|
49
|
+
"oxlint": "~1.90.0",
|
|
45
50
|
"rimraf": "^6.1.3",
|
|
46
51
|
"tsdown": "^0.23.0",
|
|
47
52
|
"typescript": "^7",
|
|
48
|
-
"vitest": "^
|
|
49
|
-
"@systemfsoftware/oxlint-ignorer-config": "^0.1.0",
|
|
50
|
-
"@systemfsoftware/tsdown-config": "^0.1.0",
|
|
51
|
-
"@systemfsoftware/vitest-config": "^0.1.0"
|
|
53
|
+
"vitest": "^5"
|
|
52
54
|
},
|
|
53
55
|
"publishConfig": {
|
|
54
56
|
"access": "public",
|
|
@@ -57,12 +59,12 @@
|
|
|
57
59
|
"scripts": {
|
|
58
60
|
"build": "tsdown",
|
|
59
61
|
"clean": "rimraf dist",
|
|
60
|
-
"typecheck": "tsc
|
|
62
|
+
"typecheck": "tsc -b",
|
|
61
63
|
"test": "vitest run",
|
|
62
64
|
"lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; oxlint . --format=${f:-default}",
|
|
63
65
|
"attw": "attw --pack .",
|
|
64
66
|
"api:check": "api-extractor run",
|
|
65
67
|
"api:update": "api-extractor run --local",
|
|
66
|
-
"lint:tsgo": "effect-tsgo diagnostics --project tsconfig.json --format ${TSGO_FORMAT:-text}"
|
|
68
|
+
"lint:tsgo": "effect-tsgo diagnostics --project tsconfig.app.json --format ${TSGO_FORMAT:-text} && effect-tsgo diagnostics --project tsconfig.test.json --format ${TSGO_FORMAT:-text}"
|
|
67
69
|
}
|
|
68
70
|
}
|