@systemfsoftware/stryker-js-mutation-report 1.2.5
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 +203 -0
- package/README.md +38 -0
- package/dist/index-B2HNaAU7.d.mts +115 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/src-C55BKn8K.mjs +615 -0
- package/dist/stryker-plugins.d.mts +2 -0
- package/dist/stryker-plugins.mjs +2 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Copyright (c) 2026 Ryan Lee (systemfsoftware)
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
|
179
|
+
|
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
181
|
+
|
|
182
|
+
To apply the Apache License to your work, attach the following
|
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
184
|
+
replaced with your own identifying information. (Don't include
|
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
186
|
+
comment syntax for the file format. We also recommend that a
|
|
187
|
+
file or class name and description of purpose be included on the
|
|
188
|
+
same "printed page" as the copyright notice for easier
|
|
189
|
+
identification within third-party archives.
|
|
190
|
+
|
|
191
|
+
Copyright 2026 Ryan Lee (systemfsoftware)
|
|
192
|
+
|
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
you may not use this file except in compliance with the License.
|
|
195
|
+
You may obtain a copy of the License at
|
|
196
|
+
|
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
|
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
|
+
See the License for the specific language governing permissions and
|
|
203
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[![NPM Version][npm-badge]][npm-url]
|
|
2
|
+
[![License: Apache 2.0][license-badge]][license-url]
|
|
3
|
+
|
|
4
|
+
# @systemfsoftware/stryker-js-mutation-report
|
|
5
|
+
|
|
6
|
+
The reporter adapters of the [System F Software][repo] StrykerJS fork —
|
|
7
|
+
clear-text, progress, HTML, JSON, and NDJSON-stream presentation.
|
|
8
|
+
|
|
9
|
+
This package is consumed by the fork's CLI ([`@systemfsoftware/stryker-js-cli`][cli])
|
|
10
|
+
and engine ([`@systemfsoftware/stryker-js-mutation-run`][engine]); it exposes
|
|
11
|
+
no public API of its own beyond the reporter classes and the `strykerPlugins`
|
|
12
|
+
registry the CLI resolves when it boots a run.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
You normally never import this package directly — the CLI wires it in. The
|
|
17
|
+
pieces exist so a programmatic consumer can assemble its own host:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { ClearTextReporter, strykerPlugins } from '@systemfsoftware/stryker-js-mutation-report'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Related
|
|
24
|
+
|
|
25
|
+
- [`@systemfsoftware/stryker-js-mutation-run`][engine] — the engine that emits the events these reporters present
|
|
26
|
+
- [`@systemfsoftware/stryker-js-cli`][cli] — the terminal-facing half, which binds this package's `strykerPlugins`
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
Licensed under [Apache 2.0][license-url].
|
|
31
|
+
|
|
32
|
+
[npm-badge]: https://img.shields.io/npm/v/@systemfsoftware/stryker-js-mutation-report?style=flat-square
|
|
33
|
+
[npm-url]: https://www.npmjs.com/package/@systemfsoftware/stryker-js-mutation-report
|
|
34
|
+
[license-badge]: https://img.shields.io/badge/license-Apache_2.0-blue?style=flat-square
|
|
35
|
+
[license-url]: https://github.com/systemfsoftware/systemfsoftware/blob/main/LICENSE
|
|
36
|
+
[repo]: https://github.com/systemfsoftware/systemfsoftware
|
|
37
|
+
[engine]: https://github.com/systemfsoftware/systemfsoftware/tree/main/packages/stryker-js/mutation-run
|
|
38
|
+
[cli]: https://github.com/systemfsoftware/systemfsoftware/tree/main/packages/stryker-js/cli
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { PluginContext, PluginKind } from "@systemfsoftware/stryker-js-plugin-api/plugin";
|
|
2
|
+
import { MutantResult, StrykerOptions, schema } from "@systemfsoftware/stryker-js-plugin-api/core";
|
|
3
|
+
import { Logger } from "@systemfsoftware/stryker-js-plugin-api/logging";
|
|
4
|
+
import { DryRunCompletedEvent, MutationTestingPlanReadyEvent, Reporter } from "@systemfsoftware/stryker-js-plugin-api/report";
|
|
5
|
+
import { MutationTestMetricsResult } from "mutation-testing-metrics";
|
|
6
|
+
import { Injector } from "typed-inject";
|
|
7
|
+
import { injectionTokens } from "@systemfsoftware/stryker-js-mutation-run/plugins";
|
|
8
|
+
import { RunEventSink } from "@systemfsoftware/stryker-js-mutation-run/run-event";
|
|
9
|
+
//#region src/clear-text-reporter.d.ts
|
|
10
|
+
declare class ClearTextReporter implements Reporter {
|
|
11
|
+
private readonly log;
|
|
12
|
+
private readonly options;
|
|
13
|
+
static inject: ["logger", "options"];
|
|
14
|
+
constructor(log: Logger, options: StrykerOptions);
|
|
15
|
+
private readonly out;
|
|
16
|
+
private readonly writeLine;
|
|
17
|
+
private readonly writeDebugLine;
|
|
18
|
+
private configConsoleColor;
|
|
19
|
+
onMutationTestReportReady(_report: schema.MutationTestResult, metrics: MutationTestMetricsResult): void;
|
|
20
|
+
private reportTests;
|
|
21
|
+
private reportMutants;
|
|
22
|
+
private statusLabel;
|
|
23
|
+
private reportMutantResult;
|
|
24
|
+
private colorSourceFileAndLocation;
|
|
25
|
+
private color;
|
|
26
|
+
private logExecutedTests;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/html-reporter.d.ts
|
|
30
|
+
declare class HtmlReporter implements Reporter {
|
|
31
|
+
private readonly options;
|
|
32
|
+
private readonly log;
|
|
33
|
+
private mainPromise;
|
|
34
|
+
constructor(options: StrykerOptions, log: Logger);
|
|
35
|
+
static readonly inject: ["options", "logger"];
|
|
36
|
+
onMutationTestReportReady(report: schema.MutationTestResult): void;
|
|
37
|
+
wrapUp(): Promise<void> | undefined;
|
|
38
|
+
private generateReport;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/json-reporter.d.ts
|
|
42
|
+
declare class JsonReporter implements Reporter {
|
|
43
|
+
private readonly options;
|
|
44
|
+
private readonly log;
|
|
45
|
+
private mainPromise;
|
|
46
|
+
constructor(options: StrykerOptions, log: Logger);
|
|
47
|
+
static readonly inject: ["options", "logger"];
|
|
48
|
+
onMutationTestReportReady(report: schema.MutationTestResult): void;
|
|
49
|
+
wrapUp(): Promise<void> | undefined;
|
|
50
|
+
private generateReport;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/progress-keeper.d.ts
|
|
54
|
+
declare abstract class ProgressKeeper implements Reporter {
|
|
55
|
+
private timer;
|
|
56
|
+
private timing;
|
|
57
|
+
private capabilities;
|
|
58
|
+
private ticksByMutantId;
|
|
59
|
+
protected progress: {
|
|
60
|
+
survived: number;
|
|
61
|
+
timedOut: number;
|
|
62
|
+
tested: number;
|
|
63
|
+
mutants: number;
|
|
64
|
+
total: number;
|
|
65
|
+
ticks: number;
|
|
66
|
+
};
|
|
67
|
+
onDryRunCompleted({ timing, capabilities }: DryRunCompletedEvent): void;
|
|
68
|
+
/**
|
|
69
|
+
* An event emitted when the mutant test plan is calculated.
|
|
70
|
+
* @param event The mutant test plan ready event
|
|
71
|
+
*/
|
|
72
|
+
onMutationTestingPlanReady({ mutantPlans }: MutationTestingPlanReadyEvent): void;
|
|
73
|
+
onMutantTested(result: MutantResult): number;
|
|
74
|
+
protected getElapsedTime(): string;
|
|
75
|
+
protected getEtc(): string;
|
|
76
|
+
private formatTime;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/progress-reporter.d.ts
|
|
80
|
+
declare class ProgressBarReporter extends ProgressKeeper {
|
|
81
|
+
private progressBar?;
|
|
82
|
+
onMutationTestingPlanReady(event: MutationTestingPlanReadyEvent): void;
|
|
83
|
+
onMutantTested(result: MutantResult): number;
|
|
84
|
+
private tick;
|
|
85
|
+
private render;
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/progress-stream-reporter.d.ts
|
|
89
|
+
/**
|
|
90
|
+
* The machine-mode progress events (R17, R19, R20): the reporter seam that
|
|
91
|
+
* turns the plan and the tested-mutant callbacks into `plan` and `mutant`
|
|
92
|
+
* run events. The sink (U4) is resolved from the plugin creator's injector
|
|
93
|
+
* at construction — the same chain core provided `injectionTokens.runEventSink`
|
|
94
|
+
* on — so an unwired chain throws here rather than pushing into a silent
|
|
95
|
+
* no-op (R2). Everything else — the mode gate, the fd-1 write path, the
|
|
96
|
+
* heartbeat, the terminal line — lives on the sink's host side, not here.
|
|
97
|
+
* This reporter writes no lines itself; it stays registered as the fifth
|
|
98
|
+
* surviving reporter name — U9 must not prune it.
|
|
99
|
+
*/
|
|
100
|
+
declare class ProgressStreamReporter implements Reporter {
|
|
101
|
+
static readonly inject: ["$injector"];
|
|
102
|
+
private total;
|
|
103
|
+
private completed;
|
|
104
|
+
constructor(injector: Injector<PluginContext & {
|
|
105
|
+
[injectionTokens.runEventSink]: RunEventSink;
|
|
106
|
+
}>);
|
|
107
|
+
private readonly runEventSink;
|
|
108
|
+
onMutationTestingPlanReady(event: MutationTestingPlanReadyEvent): void;
|
|
109
|
+
onMutantTested(result: MutantResult): void;
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/index.d.ts
|
|
113
|
+
declare const strykerPlugins: import("@systemfsoftware/stryker-js-plugin-api/plugin").ClassPlugin<PluginKind.Reporter, []>[];
|
|
114
|
+
//#endregion
|
|
115
|
+
export { HtmlReporter as a, JsonReporter as i, ProgressStreamReporter as n, ClearTextReporter as o, ProgressBarReporter as r, strykerPlugins as t };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as HtmlReporter, i as JsonReporter, n as ProgressStreamReporter, o as ClearTextReporter, r as ProgressBarReporter, t as strykerPlugins } from "./index-B2HNaAU7.mjs";
|
|
2
|
+
export { ClearTextReporter, HtmlReporter, JsonReporter, ProgressBarReporter, ProgressStreamReporter, strykerPlugins };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as HtmlReporter, i as JsonReporter, n as ProgressStreamReporter, o as ClearTextReporter, r as ProgressBarReporter, t as strykerPlugins } from "./src-C55BKn8K.mjs";
|
|
2
|
+
export { ClearTextReporter, HtmlReporter, JsonReporter, ProgressBarReporter, ProgressStreamReporter, strykerPlugins };
|
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
import { PluginKind, commonTokens, declareClassPlugin, tokens } from "@systemfsoftware/stryker-js-plugin-api/plugin";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import { PlanKind } from "@systemfsoftware/stryker-js-plugin-api/core";
|
|
4
|
+
import "@systemfsoftware/stryker-js-plugin-api/logging";
|
|
5
|
+
import "@systemfsoftware/stryker-js-plugin-api/report";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { TestStatus } from "mutation-testing-metrics";
|
|
8
|
+
import { tokens as tokens$1 } from "typed-inject";
|
|
9
|
+
import emojiRegex from "emoji-regex";
|
|
10
|
+
import fs, { createReadStream, createWriteStream, promises, rmSync } from "fs";
|
|
11
|
+
import path from "path";
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
import { pathToFileURL } from "url";
|
|
14
|
+
import ProgressBar from "progress";
|
|
15
|
+
import "@systemfsoftware/stryker-js-plugin-api/test-runner";
|
|
16
|
+
import { Timer } from "@systemfsoftware/stryker-js-mutation-run/timer";
|
|
17
|
+
import { injectionTokens } from "@systemfsoftware/stryker-js-mutation-run/plugins";
|
|
18
|
+
import { isActionableStatus } from "@systemfsoftware/stryker-js-mutation-run/verdict-envelope";
|
|
19
|
+
//#region src/render-text.ts
|
|
20
|
+
const emojiRe = emojiRegex();
|
|
21
|
+
/**
|
|
22
|
+
* The presentation-only string helpers of the clear-text reporter. They are
|
|
23
|
+
* separated from the framing helpers in the engine's `worker-pool/string-utils.ts`
|
|
24
|
+
* (which the child-process proxy and its worker depend on).
|
|
25
|
+
*/
|
|
26
|
+
function plural(items) {
|
|
27
|
+
if (items > 1) return "s";
|
|
28
|
+
else return "";
|
|
29
|
+
}
|
|
30
|
+
function getEmojiForStatus(status) {
|
|
31
|
+
switch (status) {
|
|
32
|
+
case "Killed": return "✅";
|
|
33
|
+
case "NoCoverage": return "🙈";
|
|
34
|
+
case "Ignored": return "🤥";
|
|
35
|
+
case "Survived": return "👽";
|
|
36
|
+
case "Timeout": return "⏰";
|
|
37
|
+
case "Pending": return "⌛";
|
|
38
|
+
case "RuntimeError":
|
|
39
|
+
case "CompileError": return "💥";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function stringWidth(input) {
|
|
43
|
+
let { length } = input;
|
|
44
|
+
for (const match of input.matchAll(emojiRe)) length = length - match[0].length + 2;
|
|
45
|
+
return length;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/clear-text-score-table.ts
|
|
49
|
+
const FILES_ROOT_NAME = "All files";
|
|
50
|
+
const repeat = (char, nTimes) => char.repeat(nTimes > -1 ? nTimes : 0);
|
|
51
|
+
const spaces = (n) => repeat(" ", n);
|
|
52
|
+
const determineContentWidth = (row, valueFactory, ancestorCount = 0) => {
|
|
53
|
+
return Math.max(valueFactory(row, ancestorCount).length, ...row.childResults.map((child) => determineContentWidth(child, valueFactory, ancestorCount + 1)));
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* A base class for single columns and grouped columns
|
|
57
|
+
*/
|
|
58
|
+
var Column = class {
|
|
59
|
+
header;
|
|
60
|
+
netWidth;
|
|
61
|
+
isFirstColumn;
|
|
62
|
+
/**
|
|
63
|
+
* @param header The title of the column
|
|
64
|
+
* @param netWidth The width of the column (excl 2 spaces padding)
|
|
65
|
+
* @param isFirstColumn Whether or not this is the first column in the table. If it is the first column, it should not have a space in front of it.
|
|
66
|
+
*/
|
|
67
|
+
constructor(header, netWidth, isFirstColumn) {
|
|
68
|
+
this.header = header;
|
|
69
|
+
this.netWidth = netWidth;
|
|
70
|
+
this.isFirstColumn = isFirstColumn;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Adds padding (spaces) to the front and end of a value
|
|
74
|
+
* @param input The string input
|
|
75
|
+
*/
|
|
76
|
+
pad(input = "") {
|
|
77
|
+
return `${spaces(this.netWidth - stringWidth(input))}${this.isFirstColumn ? "" : " "}${input} `;
|
|
78
|
+
}
|
|
79
|
+
drawLine() {
|
|
80
|
+
return repeat("-", this.width);
|
|
81
|
+
}
|
|
82
|
+
drawHeader() {
|
|
83
|
+
return this.pad(this.header);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The gross width of the column (including padding)
|
|
87
|
+
*/
|
|
88
|
+
get width() {
|
|
89
|
+
return this.netWidth + (this.isFirstColumn ? 1 : 2);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Represents a single column in the clear text table (no group)
|
|
94
|
+
*/
|
|
95
|
+
var SingleColumn = class extends Column {
|
|
96
|
+
valueFactory;
|
|
97
|
+
rows;
|
|
98
|
+
constructor(header, isFirstColumn, valueFactory, rows) {
|
|
99
|
+
const maxContentSize = determineContentWidth(rows, valueFactory);
|
|
100
|
+
super(header, Math.max(maxContentSize, stringWidth(header)), isFirstColumn);
|
|
101
|
+
this.valueFactory = valueFactory;
|
|
102
|
+
this.rows = rows;
|
|
103
|
+
}
|
|
104
|
+
drawTableCell(score, ancestorCount) {
|
|
105
|
+
return this.color(score)(this.pad(this.valueFactory(score, ancestorCount)));
|
|
106
|
+
}
|
|
107
|
+
color(_score) {
|
|
108
|
+
return (input) => input;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var MutationScoreColumn = class extends SingleColumn {
|
|
112
|
+
thresholds;
|
|
113
|
+
scoreType;
|
|
114
|
+
constructor(rows, thresholds, scoreType) {
|
|
115
|
+
super(scoreType, false, (row) => {
|
|
116
|
+
const score = scoreType === "total" ? row.metrics.mutationScore : row.metrics.mutationScoreBasedOnCoveredCode;
|
|
117
|
+
return isNaN(score) ? "n/a" : score.toFixed(2);
|
|
118
|
+
}, rows);
|
|
119
|
+
this.thresholds = thresholds;
|
|
120
|
+
this.scoreType = scoreType;
|
|
121
|
+
}
|
|
122
|
+
color(metricsResult) {
|
|
123
|
+
const { mutationScore: score, mutationScoreBasedOnCoveredCode: coveredScore } = metricsResult.metrics;
|
|
124
|
+
const scoreToUse = this.scoreType === "total" ? score : coveredScore;
|
|
125
|
+
if (isNaN(scoreToUse)) return chalk.grey;
|
|
126
|
+
else if (scoreToUse >= this.thresholds.high) return chalk.green;
|
|
127
|
+
else if (scoreToUse >= this.thresholds.low) return chalk.yellow;
|
|
128
|
+
else return chalk.red;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var FileColumn = class extends SingleColumn {
|
|
132
|
+
constructor(rows) {
|
|
133
|
+
super("File", true, (row, ancestorCount) => spaces(ancestorCount) + (ancestorCount === 0 ? FILES_ROOT_NAME : row.name), rows);
|
|
134
|
+
}
|
|
135
|
+
pad(input) {
|
|
136
|
+
return `${input}${spaces(this.width - stringWidth(input))}`;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var GroupColumn = class extends Column {
|
|
140
|
+
columns;
|
|
141
|
+
constructor(groupName, ...columns) {
|
|
142
|
+
const firstColumn = columns[0];
|
|
143
|
+
if (firstColumn === void 0) throw new Error("a group column needs at least one column");
|
|
144
|
+
const { isFirstColumn } = firstColumn;
|
|
145
|
+
const columnsWidth = columns.reduce((acc, cur) => acc + cur.width, 0) - (isFirstColumn ? 1 : 2);
|
|
146
|
+
const groupNameWidth = stringWidth(groupName);
|
|
147
|
+
super(groupName, Math.max(groupNameWidth, columnsWidth), isFirstColumn);
|
|
148
|
+
this.columns = columns;
|
|
149
|
+
if (this.netWidth > columnsWidth + 1) firstColumn.netWidth += this.netWidth - columnsWidth - 1;
|
|
150
|
+
}
|
|
151
|
+
drawColumnHeaders() {
|
|
152
|
+
return this.columns.map((column) => column.drawHeader()).join("|");
|
|
153
|
+
}
|
|
154
|
+
drawColumnLines() {
|
|
155
|
+
return this.columns.map((column) => column.drawLine()).join("|");
|
|
156
|
+
}
|
|
157
|
+
drawTableCell(score, ancestorCount) {
|
|
158
|
+
return this.columns.map((column) => column.drawTableCell(score, ancestorCount)).join("|");
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Represents a clear text table for mutation score
|
|
163
|
+
*/
|
|
164
|
+
var ClearTextScoreTable = class {
|
|
165
|
+
metricsResult;
|
|
166
|
+
options;
|
|
167
|
+
columns;
|
|
168
|
+
constructor(metricsResult, options) {
|
|
169
|
+
this.metricsResult = metricsResult;
|
|
170
|
+
this.options = options;
|
|
171
|
+
this.columns = [
|
|
172
|
+
new GroupColumn("", new FileColumn(metricsResult)),
|
|
173
|
+
new GroupColumn("% Mutation score", new MutationScoreColumn(metricsResult, options.thresholds, "total"), new MutationScoreColumn(metricsResult, options.thresholds, "covered")),
|
|
174
|
+
new GroupColumn("", new SingleColumn(`${options.clearTextReporter.allowEmojis ? "✅" : "#"} killed`, false, (row) => row.metrics.killed.toString(), metricsResult)),
|
|
175
|
+
new GroupColumn("", new SingleColumn(`${options.clearTextReporter.allowEmojis ? "⌛️" : "#"} timeout`, false, (row) => row.metrics.timeout.toString(), metricsResult)),
|
|
176
|
+
new GroupColumn("", new SingleColumn(`${options.clearTextReporter.allowEmojis ? "👽" : "#"} survived`, false, (row) => row.metrics.survived.toString(), metricsResult)),
|
|
177
|
+
new GroupColumn("", new SingleColumn(`${options.clearTextReporter.allowEmojis ? "🙈" : "#"} no cov`, false, (row) => row.metrics.noCoverage.toString(), metricsResult)),
|
|
178
|
+
new GroupColumn("", new SingleColumn(`${options.clearTextReporter.allowEmojis ? "💥" : "#"} errors`, false, (row) => (row.metrics.runtimeErrors + row.metrics.compileErrors).toString(), metricsResult))
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
drawGroupHeader() {
|
|
182
|
+
return this.drawRow((column) => column.drawHeader());
|
|
183
|
+
}
|
|
184
|
+
drawGroupLine() {
|
|
185
|
+
return this.drawRow((column) => column.drawLine());
|
|
186
|
+
}
|
|
187
|
+
drawLine() {
|
|
188
|
+
return this.drawRow((column) => column.drawColumnLines());
|
|
189
|
+
}
|
|
190
|
+
drawColumnHeader() {
|
|
191
|
+
return this.drawRow((c) => c.drawColumnHeaders());
|
|
192
|
+
}
|
|
193
|
+
drawRow(toDraw) {
|
|
194
|
+
return this.columns.map(toDraw).join("|") + "|";
|
|
195
|
+
}
|
|
196
|
+
drawTableBody(current = this.metricsResult, ancestorCount = 0) {
|
|
197
|
+
const rows = [];
|
|
198
|
+
if (!this.options.clearTextReporter.skipFull || current.metrics.mutationScore !== 100) rows.push(this.drawRow((c) => c.drawTableCell(current, ancestorCount)));
|
|
199
|
+
rows.push(...current.childResults.flatMap((child) => this.drawTableBody(child, ancestorCount + 1)));
|
|
200
|
+
return rows;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Returns a string with the score results drawn in a table.
|
|
204
|
+
*/
|
|
205
|
+
draw() {
|
|
206
|
+
return [
|
|
207
|
+
this.drawGroupLine(),
|
|
208
|
+
this.drawGroupHeader(),
|
|
209
|
+
this.drawColumnHeader(),
|
|
210
|
+
this.drawLine(),
|
|
211
|
+
this.drawTableBody().join(os.EOL),
|
|
212
|
+
this.drawLine()
|
|
213
|
+
].join(os.EOL);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/clear-text-reporter.ts
|
|
218
|
+
var ClearTextReporter = class {
|
|
219
|
+
log;
|
|
220
|
+
options;
|
|
221
|
+
static inject = tokens$1(commonTokens.logger, commonTokens.options);
|
|
222
|
+
constructor(log, options) {
|
|
223
|
+
this.log = log;
|
|
224
|
+
this.options = options;
|
|
225
|
+
this.configConsoleColor();
|
|
226
|
+
}
|
|
227
|
+
out = process.stdout;
|
|
228
|
+
writeLine = (output) => {
|
|
229
|
+
this.out.write(`${output ?? ""}${os.EOL}`);
|
|
230
|
+
};
|
|
231
|
+
writeDebugLine = (input) => {
|
|
232
|
+
this.log.debug(input);
|
|
233
|
+
};
|
|
234
|
+
configConsoleColor() {
|
|
235
|
+
if (!this.options.allowConsoleColors) chalk.level = 0;
|
|
236
|
+
}
|
|
237
|
+
onMutationTestReportReady(_report, metrics) {
|
|
238
|
+
this.writeLine();
|
|
239
|
+
if (this.options.clearTextReporter.reportTests) this.reportTests(metrics);
|
|
240
|
+
if (this.options.clearTextReporter.reportMutants) this.reportMutants(metrics);
|
|
241
|
+
if (this.options.clearTextReporter.reportScoreTable && (!this.options.clearTextReporter.skipFull || metrics.systemUnderTestMetrics.childResults.some((x) => x.metrics.mutationScore !== 100))) this.writeLine(new ClearTextScoreTable(metrics.systemUnderTestMetrics, this.options).draw());
|
|
242
|
+
}
|
|
243
|
+
reportTests(metrics) {
|
|
244
|
+
function indent(depth) {
|
|
245
|
+
return Array.from({ length: depth }, () => " ").join("");
|
|
246
|
+
}
|
|
247
|
+
const formatTestLine = (test, state) => {
|
|
248
|
+
return `${this.color("grey", `${test.name}${test.location ? ` [line ${test.location.start.line}]` : ""}`)} (${state})`;
|
|
249
|
+
};
|
|
250
|
+
if (metrics.testMetrics) {
|
|
251
|
+
const reportTests = (currentResult, depth = 0) => {
|
|
252
|
+
const nameParts = [currentResult.name];
|
|
253
|
+
while (!currentResult.file && currentResult.childResults.length === 1) {
|
|
254
|
+
const onlyChild = currentResult.childResults[0];
|
|
255
|
+
if (onlyChild === void 0) break;
|
|
256
|
+
currentResult = onlyChild;
|
|
257
|
+
nameParts.push(currentResult.name);
|
|
258
|
+
}
|
|
259
|
+
this.writeLine(`${indent(depth)}${nameParts.join("/")}`);
|
|
260
|
+
currentResult.file?.tests.forEach((test) => {
|
|
261
|
+
switch (test.status) {
|
|
262
|
+
case TestStatus.Killing:
|
|
263
|
+
this.writeLine(`${indent(depth + 1)}${this.color("greenBright", "✓")} ${formatTestLine(test, `killed ${test.killedMutants?.length}`)}`);
|
|
264
|
+
break;
|
|
265
|
+
case TestStatus.Covering:
|
|
266
|
+
this.writeLine(`${indent(depth + 1)}${this.color("blueBright", "~")} ${formatTestLine(test, `covered ${test.coveredMutants?.length}`)}`);
|
|
267
|
+
break;
|
|
268
|
+
case TestStatus.NotCovering: this.writeLine(`${indent(depth + 1)}${this.color("redBright", "✘")} ${formatTestLine(test, "covered 0")}`);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
currentResult.childResults.forEach((childResult) => reportTests(childResult, depth + 1));
|
|
272
|
+
};
|
|
273
|
+
reportTests(metrics.testMetrics);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
reportMutants({ systemUnderTestMetrics }) {
|
|
277
|
+
this.writeLine();
|
|
278
|
+
let totalTests = 0;
|
|
279
|
+
const reportMutants = (metrics) => {
|
|
280
|
+
metrics.forEach((child) => {
|
|
281
|
+
child.file?.mutants.forEach((result) => {
|
|
282
|
+
totalTests += result.testsCompleted ?? 0;
|
|
283
|
+
switch (result.status) {
|
|
284
|
+
case "Killed":
|
|
285
|
+
case "Timeout":
|
|
286
|
+
case "RuntimeError":
|
|
287
|
+
case "CompileError":
|
|
288
|
+
this.reportMutantResult(result, this.writeDebugLine);
|
|
289
|
+
break;
|
|
290
|
+
case "Survived":
|
|
291
|
+
case "NoCoverage": this.reportMutantResult(result, this.writeLine);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
reportMutants(child.childResults);
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
reportMutants(systemUnderTestMetrics.childResults);
|
|
298
|
+
this.writeLine(`Ran ${(totalTests / systemUnderTestMetrics.metrics.totalMutants).toFixed(2)} tests per mutant on average.`);
|
|
299
|
+
}
|
|
300
|
+
statusLabel(mutant) {
|
|
301
|
+
const { status } = mutant;
|
|
302
|
+
return this.options.clearTextReporter.allowEmojis ? `${getEmojiForStatus(status)} ${status}` : status.toString();
|
|
303
|
+
}
|
|
304
|
+
reportMutantResult(result, logImplementation) {
|
|
305
|
+
logImplementation(`[${this.statusLabel(result)}] ${result.mutatorName}`);
|
|
306
|
+
logImplementation(this.colorSourceFileAndLocation(result.fileName, result.location.start));
|
|
307
|
+
result.getOriginalLines().split("\n").filter(Boolean).forEach((line) => {
|
|
308
|
+
logImplementation(chalk.red("- " + line));
|
|
309
|
+
});
|
|
310
|
+
result.getMutatedLines().split("\n").filter(Boolean).forEach((line) => {
|
|
311
|
+
logImplementation(chalk.green("+ " + line));
|
|
312
|
+
});
|
|
313
|
+
if (result.status === "Survived") {
|
|
314
|
+
if (result.static) logImplementation("Ran all tests for this mutant.");
|
|
315
|
+
else if (result.coveredByTests) this.logExecutedTests(result.coveredByTests, logImplementation);
|
|
316
|
+
} else if (result.status === "Killed" && result.killedByTests?.length) {
|
|
317
|
+
const firstKiller = result.killedByTests[0];
|
|
318
|
+
if (firstKiller !== void 0) logImplementation(`Killed by: ${firstKiller.name}`);
|
|
319
|
+
} else if (result.status === "RuntimeError" || result.status === "CompileError") logImplementation(`Error message: ${result.statusReason}`);
|
|
320
|
+
logImplementation("");
|
|
321
|
+
}
|
|
322
|
+
colorSourceFileAndLocation(fileName, position) {
|
|
323
|
+
return [
|
|
324
|
+
this.color("cyan", fileName),
|
|
325
|
+
this.color("yellow", position.line),
|
|
326
|
+
this.color("yellow", position.column)
|
|
327
|
+
].join(":");
|
|
328
|
+
}
|
|
329
|
+
color(color, ...text) {
|
|
330
|
+
if (this.options.clearTextReporter.allowColor) return chalk[color](...text);
|
|
331
|
+
return text.join("");
|
|
332
|
+
}
|
|
333
|
+
logExecutedTests(tests, logImplementation) {
|
|
334
|
+
if (!this.options.clearTextReporter.logTests) return;
|
|
335
|
+
const testCount = Math.min(this.options.clearTextReporter.maxTestsToLog, tests.length);
|
|
336
|
+
if (testCount > 0) {
|
|
337
|
+
logImplementation("Tests ran:");
|
|
338
|
+
tests.slice(0, testCount).forEach((test) => {
|
|
339
|
+
logImplementation(` ${test.name}`);
|
|
340
|
+
});
|
|
341
|
+
const diff = tests.length - this.options.clearTextReporter.maxTestsToLog;
|
|
342
|
+
if (diff > 0) logImplementation(` and ${diff} more test${plural(diff)}!`);
|
|
343
|
+
logImplementation("");
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/reporter-util.ts
|
|
349
|
+
const reporterUtil = {
|
|
350
|
+
copyFile(fromFilename, toFilename) {
|
|
351
|
+
return new Promise((resolve, reject) => {
|
|
352
|
+
const readStream = createReadStream(fromFilename);
|
|
353
|
+
const writeStream = createWriteStream(toFilename);
|
|
354
|
+
readStream.on("error", reject);
|
|
355
|
+
writeStream.on("error", reject);
|
|
356
|
+
readStream.pipe(writeStream);
|
|
357
|
+
readStream.on("end", resolve);
|
|
358
|
+
});
|
|
359
|
+
},
|
|
360
|
+
async writeFile(fileName, content) {
|
|
361
|
+
await promises.mkdir(path.dirname(fileName), { recursive: true });
|
|
362
|
+
await promises.writeFile(fileName, content, "utf8");
|
|
363
|
+
},
|
|
364
|
+
removeFileSync(fileName) {
|
|
365
|
+
rmSync(fileName, { force: true });
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/html-reporter.ts
|
|
370
|
+
var HtmlReporter = class {
|
|
371
|
+
options;
|
|
372
|
+
log;
|
|
373
|
+
mainPromise;
|
|
374
|
+
constructor(options, log) {
|
|
375
|
+
this.options = options;
|
|
376
|
+
this.log = log;
|
|
377
|
+
}
|
|
378
|
+
static inject = tokens(commonTokens.options, commonTokens.logger);
|
|
379
|
+
onMutationTestReportReady(report) {
|
|
380
|
+
this.mainPromise = this.generateReport(report);
|
|
381
|
+
}
|
|
382
|
+
wrapUp() {
|
|
383
|
+
return this.mainPromise;
|
|
384
|
+
}
|
|
385
|
+
async generateReport(report) {
|
|
386
|
+
this.log.debug(`Using file "${this.options.htmlReporter.fileName}"`);
|
|
387
|
+
const html = await createReportHtml(report);
|
|
388
|
+
await reporterUtil.writeFile(this.options.htmlReporter.fileName, html);
|
|
389
|
+
this.log.info(`Your report can be found at: ${pathToFileURL(path.resolve(this.options.htmlReporter.fileName)).href}`);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
async function createReportHtml(report) {
|
|
393
|
+
const require = createRequire(import.meta.url);
|
|
394
|
+
return `<!DOCTYPE html>
|
|
395
|
+
<html>
|
|
396
|
+
<head>
|
|
397
|
+
<meta charset="utf-8">
|
|
398
|
+
<script>
|
|
399
|
+
${await fs.promises.readFile(require.resolve("mutation-testing-elements/dist/mutation-test-elements.js"), "utf-8")}
|
|
400
|
+
<\/script>
|
|
401
|
+
</head>
|
|
402
|
+
<body>
|
|
403
|
+
<svg style="width: 80px; position:fixed; right:10px; bottom:10px; z-index:10" class="stryker-image" viewBox="0 0 1458 1458" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><path fill="none" d="M0 0h1458v1458H0z"/><clipPath id="a"><path d="M0 0h1458v1458H0z"/></clipPath><g clip-path="url(#a)"><path d="M1458 729c0 402.655-326.345 729-729 729S0 1131.655 0 729C0 326.445 326.345 0 729 0s729 326.345 729 729" fill="#e74c3c" fill-rule="nonzero"/><path d="M778.349 1456.15L576.6 1254.401l233-105 85-78.668v-64.332l-257-257-44-187-50-208 251.806-82.793L1076.6 389.401l380.14 379.15c-19.681 367.728-311.914 663.049-678.391 687.599z" fill-opacity=".3"/><path d="M753.4 329.503c41.79 0 74.579 7.83 97.925 25.444 23.571 18.015 41.69 43.956 55.167 77.097l11.662 28.679 165.733-58.183-14.137-32.13c-26.688-60.655-64.896-108.61-114.191-144.011-49.329-35.423-117.458-54.302-204.859-54.302-50.78 0-95.646 7.376-134.767 21.542-40.093 14.671-74.09 34.79-102.239 60.259-28.84 26.207-50.646 57.06-65.496 92.701-14.718 35.052-22.101 72.538-22.101 112.401 0 72.536 20.667 133.294 61.165 182.704 38.624 47.255 98.346 88.037 179.861 121.291 42.257 17.475 78.715 33.125 109.227 46.994 27.193 12.361 49.294 26.124 66.157 41.751 15.309 14.186 26.497 30.584 33.63 49.258 7.721 20.214 11.16 45.69 11.16 76.402 0 28.021-4.251 51.787-13.591 71.219-8.832 18.374-20.171 33.178-34.523 44.219-14.787 11.374-31.193 19.591-49.393 24.466-19.68 5.359-39.14 7.993-58.69 7.993-29.359 0-54.387-3.407-75.182-10.747-20.112-7.013-37.144-16.144-51.259-27.486-13.618-11.009-24.971-23.766-33.744-38.279-9.64-15.8-17.272-31.924-23.032-48.408l-10.965-31.376-161.669 60.585 10.734 30.124c10.191 28.601 24.197 56.228 42.059 82.748 18.208 27.144 41.322 51.369 69.525 72.745 27.695 21.075 60.904 38.218 99.481 51.041 37.777 12.664 82.004 19.159 132.552 19.159 49.998 0 95.818-8.321 137.611-24.622 42.228-16.471 78.436-38.992 108.835-67.291 30.719-28.597 54.631-62.103 71.834-100.642 17.263-38.56 25.923-79.392 25.923-122.248 0-54.339-8.368-100.37-24.208-138.32-16.29-38.759-38.252-71.661-65.948-98.797-26.965-26.418-58.269-48.835-93.858-67.175-33.655-17.241-69.196-33.11-106.593-47.533-35.934-13.429-65.822-26.601-89.948-39.525-22.153-11.868-40.009-24.21-53.547-37.309-11.429-11.13-19.83-23.678-24.718-37.664-5.413-15.49-7.98-33.423-7.98-53.577 0-40.883 11.293-71.522 37.086-90.539 28.443-20.825 64.985-30.658 109.311-30.658z" fill="#f1c40f" fill-rule="nonzero"/><path d="M720 0h18v113h-18zM1458 738v-18h-113v18h113zM720 1345h18v113h-18zM113 738v-18H0v18h113z"/></g></svg>
|
|
404
|
+
<mutation-test-report-app titlePostfix="Stryker">
|
|
405
|
+
Your browser doesn't support <a href="https://caniuse.com/#search=custom%20elements">custom elements</a>.
|
|
406
|
+
Please use a latest version of an evergreen browser (Firefox, Chrome, Safari, Opera, Edge, etc).
|
|
407
|
+
</mutation-test-report-app>
|
|
408
|
+
<script>
|
|
409
|
+
const app = document.querySelector('mutation-test-report-app');
|
|
410
|
+
app.report = ${escapeHtmlTags(JSON.stringify(report))};
|
|
411
|
+
function updateTheme() {
|
|
412
|
+
document.body.style.backgroundColor = app.themeBackgroundColor;
|
|
413
|
+
}
|
|
414
|
+
app.addEventListener('theme-changed', updateTheme);
|
|
415
|
+
updateTheme();
|
|
416
|
+
<\/script>
|
|
417
|
+
</body>
|
|
418
|
+
</html>`;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Escapes the HTML tags inside strings in a JSON input by breaking them apart.
|
|
422
|
+
*/
|
|
423
|
+
function escapeHtmlTags(json) {
|
|
424
|
+
return json.replace(/</g, "<\"+\"");
|
|
425
|
+
}
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/json-reporter.ts
|
|
428
|
+
const INDENTION_LEVEL = 0;
|
|
429
|
+
var JsonReporter = class {
|
|
430
|
+
options;
|
|
431
|
+
log;
|
|
432
|
+
mainPromise;
|
|
433
|
+
constructor(options, log) {
|
|
434
|
+
this.options = options;
|
|
435
|
+
this.log = log;
|
|
436
|
+
/**
|
|
437
|
+
* A run that dies before `onMutationTestReportReady` never writes, so the previous
|
|
438
|
+
* run's report stays on disk and every consumer reads it as a description of the run
|
|
439
|
+
* that just failed. Measured 2026-08-01 on omp-claude-compat: three checker-init
|
|
440
|
+
* failures left a stale report that a contribution checker read as evidence two test
|
|
441
|
+
* files defended nothing — one of them defends two mutants. `BroadcastReporter`
|
|
442
|
+
* constructs every reporter once, before the dry run, so clearing here makes the
|
|
443
|
+
* file's presence mean the run reached the end. Synchronous on purpose: the write
|
|
444
|
+
* happens much later and must not race a pending unlink.
|
|
445
|
+
*/
|
|
446
|
+
reporterUtil.removeFileSync(path.resolve(path.normalize(options.jsonReporter.fileName)));
|
|
447
|
+
}
|
|
448
|
+
static inject = tokens(commonTokens.options, commonTokens.logger);
|
|
449
|
+
onMutationTestReportReady(report) {
|
|
450
|
+
this.mainPromise = this.generateReport(report);
|
|
451
|
+
}
|
|
452
|
+
wrapUp() {
|
|
453
|
+
return this.mainPromise;
|
|
454
|
+
}
|
|
455
|
+
async generateReport(report) {
|
|
456
|
+
const filePath = path.normalize(this.options.jsonReporter.fileName);
|
|
457
|
+
this.log.debug(`Using relative path ${filePath}`);
|
|
458
|
+
await reporterUtil.writeFile(path.resolve(filePath), JSON.stringify(report, null, INDENTION_LEVEL));
|
|
459
|
+
this.log.info(`Your report can be found at: ${pathToFileURL(filePath).href}`);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/progress-bar.ts
|
|
464
|
+
/**
|
|
465
|
+
* Wrapper around the progress bar for unit testing purposes
|
|
466
|
+
*/
|
|
467
|
+
const progressBarWrapper = { ProgressBar };
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/progress-keeper.ts
|
|
470
|
+
var ProgressKeeper = class {
|
|
471
|
+
timer;
|
|
472
|
+
timing;
|
|
473
|
+
capabilities;
|
|
474
|
+
ticksByMutantId;
|
|
475
|
+
progress = {
|
|
476
|
+
survived: 0,
|
|
477
|
+
timedOut: 0,
|
|
478
|
+
tested: 0,
|
|
479
|
+
mutants: 0,
|
|
480
|
+
total: 0,
|
|
481
|
+
ticks: 0
|
|
482
|
+
};
|
|
483
|
+
onDryRunCompleted({ timing, capabilities }) {
|
|
484
|
+
this.timing = timing;
|
|
485
|
+
this.capabilities = capabilities;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* An event emitted when the mutant test plan is calculated.
|
|
489
|
+
* @param event The mutant test plan ready event
|
|
490
|
+
*/
|
|
491
|
+
onMutationTestingPlanReady({ mutantPlans }) {
|
|
492
|
+
this.timer = new Timer();
|
|
493
|
+
this.ticksByMutantId = new Map(mutantPlans.filter(isRunPlan).map(({ netTime, mutant, runOptions }) => {
|
|
494
|
+
let ticks = netTime;
|
|
495
|
+
if (!this.capabilities.reloadEnvironment && runOptions.reloadEnvironment) ticks += this.timing.overhead;
|
|
496
|
+
return [mutant.id, ticks];
|
|
497
|
+
}));
|
|
498
|
+
this.progress.mutants = this.ticksByMutantId.size;
|
|
499
|
+
this.progress.total = [...this.ticksByMutantId.values()].reduce((acc, n) => acc + n, 0);
|
|
500
|
+
}
|
|
501
|
+
onMutantTested(result) {
|
|
502
|
+
const ticks = this.ticksByMutantId.get(result.id);
|
|
503
|
+
if (ticks !== void 0) {
|
|
504
|
+
this.progress.tested++;
|
|
505
|
+
this.progress.ticks += this.ticksByMutantId.get(result.id) ?? 0;
|
|
506
|
+
if (result.status === "Survived") this.progress.survived++;
|
|
507
|
+
if (result.status === "Timeout") this.progress.timedOut++;
|
|
508
|
+
}
|
|
509
|
+
return ticks ?? 0;
|
|
510
|
+
}
|
|
511
|
+
getElapsedTime() {
|
|
512
|
+
return this.formatTime(this.timer.elapsedSeconds());
|
|
513
|
+
}
|
|
514
|
+
getEtc() {
|
|
515
|
+
const totalSecondsLeft = Math.floor(this.timer.elapsedSeconds() / this.progress.ticks * (this.progress.total - this.progress.ticks));
|
|
516
|
+
if (isFinite(totalSecondsLeft) && totalSecondsLeft > 0) return this.formatTime(totalSecondsLeft);
|
|
517
|
+
else return "n/a";
|
|
518
|
+
}
|
|
519
|
+
formatTime(timeInSeconds) {
|
|
520
|
+
const hours = Math.floor(timeInSeconds / 3600);
|
|
521
|
+
const minutes = Math.floor(timeInSeconds % 3600 / 60);
|
|
522
|
+
return hours > 0 ? `~${hours}h ${minutes}m` : minutes > 0 ? `~${minutes}m` : "<1m";
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
function isRunPlan(mutantPlan) {
|
|
526
|
+
return mutantPlan.plan === PlanKind.Run;
|
|
527
|
+
}
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region src/progress-reporter.ts
|
|
530
|
+
var ProgressBarReporter = class extends ProgressKeeper {
|
|
531
|
+
progressBar;
|
|
532
|
+
onMutationTestingPlanReady(event) {
|
|
533
|
+
super.onMutationTestingPlanReady(event);
|
|
534
|
+
const progressBarContent = "Mutation testing [:bar] :percent (elapsed: :et, remaining: :etc) :tested/:mutants Mutants tested (:survived survived, :timedOut timed out)";
|
|
535
|
+
this.progressBar = new progressBarWrapper.ProgressBar(progressBarContent, {
|
|
536
|
+
complete: "=",
|
|
537
|
+
incomplete: " ",
|
|
538
|
+
stream: process.stdout,
|
|
539
|
+
total: this.progress.total,
|
|
540
|
+
width: 50
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
onMutantTested(result) {
|
|
544
|
+
const ticks = super.onMutantTested(result);
|
|
545
|
+
const progressBarContent = {
|
|
546
|
+
...this.progress,
|
|
547
|
+
et: this.getElapsedTime(),
|
|
548
|
+
etc: this.getEtc()
|
|
549
|
+
};
|
|
550
|
+
if (ticks) this.tick(ticks, progressBarContent);
|
|
551
|
+
else this.render(progressBarContent);
|
|
552
|
+
return ticks;
|
|
553
|
+
}
|
|
554
|
+
tick(ticks, tickObj) {
|
|
555
|
+
this.progressBar?.tick(ticks, tickObj);
|
|
556
|
+
}
|
|
557
|
+
render(renderObj) {
|
|
558
|
+
if (this.progressBar?.total) this.progressBar.render(renderObj);
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/progress-stream-reporter.ts
|
|
563
|
+
/**
|
|
564
|
+
* The machine-mode progress events (R17, R19, R20): the reporter seam that
|
|
565
|
+
* turns the plan and the tested-mutant callbacks into `plan` and `mutant`
|
|
566
|
+
* run events. The sink (U4) is resolved from the plugin creator's injector
|
|
567
|
+
* at construction — the same chain core provided `injectionTokens.runEventSink`
|
|
568
|
+
* on — so an unwired chain throws here rather than pushing into a silent
|
|
569
|
+
* no-op (R2). Everything else — the mode gate, the fd-1 write path, the
|
|
570
|
+
* heartbeat, the terminal line — lives on the sink's host side, not here.
|
|
571
|
+
* This reporter writes no lines itself; it stays registered as the fifth
|
|
572
|
+
* surviving reporter name — U9 must not prune it.
|
|
573
|
+
*/
|
|
574
|
+
var ProgressStreamReporter = class {
|
|
575
|
+
static inject = tokens$1(commonTokens.injector);
|
|
576
|
+
total = 0;
|
|
577
|
+
completed = 0;
|
|
578
|
+
constructor(injector) {
|
|
579
|
+
this.runEventSink = injector.resolve(injectionTokens.runEventSink);
|
|
580
|
+
}
|
|
581
|
+
runEventSink;
|
|
582
|
+
onMutationTestingPlanReady(event) {
|
|
583
|
+
this.total = event.mutantPlans.length;
|
|
584
|
+
this.runEventSink({
|
|
585
|
+
kind: "plan",
|
|
586
|
+
total: this.total
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
onMutantTested(result) {
|
|
590
|
+
this.completed += 1;
|
|
591
|
+
if (!isActionableStatus(result.status)) return;
|
|
592
|
+
this.runEventSink({
|
|
593
|
+
kind: "mutant",
|
|
594
|
+
id: result.id,
|
|
595
|
+
status: result.status,
|
|
596
|
+
file: result.fileName,
|
|
597
|
+
location: result.location,
|
|
598
|
+
mutator: result.mutatorName,
|
|
599
|
+
replacement: result.replacement ?? null,
|
|
600
|
+
completed: this.completed,
|
|
601
|
+
total: this.total
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
//#endregion
|
|
606
|
+
//#region src/index.ts
|
|
607
|
+
const strykerPlugins = [
|
|
608
|
+
declareClassPlugin(PluginKind.Reporter, "clear-text", ClearTextReporter),
|
|
609
|
+
declareClassPlugin(PluginKind.Reporter, "progress", ProgressBarReporter),
|
|
610
|
+
declareClassPlugin(PluginKind.Reporter, "html", HtmlReporter),
|
|
611
|
+
declareClassPlugin(PluginKind.Reporter, "json", JsonReporter),
|
|
612
|
+
declareClassPlugin(PluginKind.Reporter, "progress-stream", ProgressStreamReporter)
|
|
613
|
+
];
|
|
614
|
+
//#endregion
|
|
615
|
+
export { HtmlReporter as a, JsonReporter as i, ProgressStreamReporter as n, ClearTextReporter as o, ProgressBarReporter as r, strykerPlugins as t };
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@systemfsoftware/stryker-js-mutation-report",
|
|
3
|
+
"version": "1.2.5",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/systemfsoftware/systemfsoftware.git",
|
|
7
|
+
"directory": "packages/stryker-js/mutation-report"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/systemfsoftware/systemfsoftware/tree/main/packages/stryker-js/mutation-report#readme",
|
|
10
|
+
"bugs": "https://github.com/systemfsoftware/systemfsoftware/issues",
|
|
11
|
+
"description": "The reporter adapters of the @systemfsoftware Stryker fork — clear-text, progress, HTML, JSON, and NDJSON-stream presentation.",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@stryker-mutator/api": "^9.6.1",
|
|
18
|
+
"chalk": "~5.6.0",
|
|
19
|
+
"emoji-regex": "~10.6.0",
|
|
20
|
+
"mutation-testing-elements": "3.7.3",
|
|
21
|
+
"mutation-testing-metrics": "3.7.3",
|
|
22
|
+
"progress": "~2.0.3",
|
|
23
|
+
"typed-inject": "~5.0.0",
|
|
24
|
+
"@systemfsoftware/stryker-js-plugin-api": "^0.1.0",
|
|
25
|
+
"@systemfsoftware/stryker-js-mutation-run": "^1.2.5"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@microsoft/api-extractor": "^7.58.7",
|
|
29
|
+
"@systemfsoftware/arethetypeswrong-cli": "^1.1.1",
|
|
30
|
+
"@types/node": "^24",
|
|
31
|
+
"@types/progress": "2.0.7",
|
|
32
|
+
"effect": "4.0.0-rc.108",
|
|
33
|
+
"oxlint": "^1.77.0",
|
|
34
|
+
"rimraf": "^6.1.3",
|
|
35
|
+
"tsdown": "^0.22.14",
|
|
36
|
+
"typescript": "^7",
|
|
37
|
+
"vitest": "^4.1.10",
|
|
38
|
+
"@systemfsoftware/effect-gherkin-spec": "^0.5.1",
|
|
39
|
+
"@systemfsoftware/oxlint-config": "^0.1.0",
|
|
40
|
+
"@systemfsoftware/tsconfig": "^1.3.1",
|
|
41
|
+
"@systemfsoftware/vitest-config": "^0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20.0.0"
|
|
45
|
+
},
|
|
46
|
+
"license": "Apache-2.0",
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"provenance": true
|
|
49
|
+
},
|
|
50
|
+
"exports": {
|
|
51
|
+
".": "./dist/index.mjs",
|
|
52
|
+
"./stryker-plugins": "./dist/stryker-plugins.mjs",
|
|
53
|
+
"./package.json": "./package.json"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"clean": "rimraf dist",
|
|
57
|
+
"build": "tsdown && pnpm api:check",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"attw": "attw --pack .",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; oxlint --format=${f:-default}",
|
|
62
|
+
"api:check": "api-extractor run",
|
|
63
|
+
"api:update": "api-extractor run --local"
|
|
64
|
+
}
|
|
65
|
+
}
|