@d-es-ign/stryker-js-api 9.6.0
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 +201 -0
- package/README.md +25 -0
- package/core.d.ts +3 -0
- package/dist/schema/stryker-core.json +567 -0
- package/dist/src/check/check-result.d.ts +10 -0
- package/dist/src/check/check-result.d.ts.map +1 -0
- package/dist/src/check/check-result.js +2 -0
- package/dist/src/check/check-result.js.map +1 -0
- package/dist/src/check/check-status.d.ts +5 -0
- package/dist/src/check/check-status.d.ts.map +1 -0
- package/dist/src/check/check-status.js +6 -0
- package/dist/src/check/check-status.js.map +1 -0
- package/dist/src/check/checker.d.ts +19 -0
- package/dist/src/check/checker.d.ts.map +1 -0
- package/dist/src/check/checker.js +2 -0
- package/dist/src/check/checker.js.map +1 -0
- package/dist/src/check/index.d.ts +4 -0
- package/dist/src/check/index.d.ts.map +1 -0
- package/dist/src/check/index.js +4 -0
- package/dist/src/check/index.js.map +1 -0
- package/dist/src/check/mutant-status.d.ts +11 -0
- package/dist/src/check/mutant-status.d.ts.map +1 -0
- package/dist/src/check/mutant-status.js +12 -0
- package/dist/src/check/mutant-status.js.map +1 -0
- package/dist/src/core/file-description.d.ts +13 -0
- package/dist/src/core/file-description.d.ts.map +1 -0
- package/dist/src/core/file-description.js +2 -0
- package/dist/src/core/file-description.js.map +1 -0
- package/dist/src/core/index.d.ts +17 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +15 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/instrument.d.ts +21 -0
- package/dist/src/core/instrument.d.ts.map +1 -0
- package/dist/src/core/instrument.js +16 -0
- package/dist/src/core/instrument.js.map +1 -0
- package/dist/src/core/location.d.ts +9 -0
- package/dist/src/core/location.d.ts.map +1 -0
- package/dist/src/core/location.js +2 -0
- package/dist/src/core/location.js.map +1 -0
- package/dist/src/core/mutant-coverage.d.ts +10 -0
- package/dist/src/core/mutant-coverage.d.ts.map +1 -0
- package/dist/src/core/mutant-coverage.js +2 -0
- package/dist/src/core/mutant-coverage.js.map +1 -0
- package/dist/src/core/mutant-test-plan.d.ts +52 -0
- package/dist/src/core/mutant-test-plan.d.ts.map +1 -0
- package/dist/src/core/mutant-test-plan.js +15 -0
- package/dist/src/core/mutant-test-plan.js.map +1 -0
- package/dist/src/core/mutant.d.ts +36 -0
- package/dist/src/core/mutant.d.ts.map +1 -0
- package/dist/src/core/mutant.js +2 -0
- package/dist/src/core/mutant.js.map +1 -0
- package/dist/src/core/mutation-range.d.ts +15 -0
- package/dist/src/core/mutation-range.d.ts.map +1 -0
- package/dist/src/core/mutation-range.js +2 -0
- package/dist/src/core/mutation-range.js.map +1 -0
- package/dist/src/core/partial-stryker-options.d.ts +12 -0
- package/dist/src/core/partial-stryker-options.d.ts.map +1 -0
- package/dist/src/core/partial-stryker-options.js +2 -0
- package/dist/src/core/partial-stryker-options.js.map +1 -0
- package/dist/src/core/position.d.ts +9 -0
- package/dist/src/core/position.d.ts.map +1 -0
- package/dist/src/core/position.js +2 -0
- package/dist/src/core/position.js.map +1 -0
- package/dist/src/core/report-types.d.ts +3 -0
- package/dist/src/core/report-types.d.ts.map +1 -0
- package/dist/src/core/report-types.js +5 -0
- package/dist/src/core/report-types.js.map +1 -0
- package/dist/src/core/stryker-options-schema.d.ts +3 -0
- package/dist/src/core/stryker-options-schema.d.ts.map +1 -0
- package/dist/src/core/stryker-options-schema.js +5 -0
- package/dist/src/core/stryker-options-schema.js.map +1 -0
- package/dist/src/ignore/ignorer.d.ts +6 -0
- package/dist/src/ignore/ignorer.d.ts.map +1 -0
- package/dist/src/ignore/ignorer.js +2 -0
- package/dist/src/ignore/ignorer.js.map +1 -0
- package/dist/src/ignore/index.d.ts +2 -0
- package/dist/src/ignore/index.d.ts.map +1 -0
- package/dist/src/ignore/index.js +2 -0
- package/dist/src/ignore/index.js.map +1 -0
- package/dist/src/logging/index.d.ts +3 -0
- package/dist/src/logging/index.d.ts.map +1 -0
- package/dist/src/logging/index.js +2 -0
- package/dist/src/logging/index.js.map +1 -0
- package/dist/src/logging/logger-factory-method.d.ts +10 -0
- package/dist/src/logging/logger-factory-method.d.ts.map +1 -0
- package/dist/src/logging/logger-factory-method.js +2 -0
- package/dist/src/logging/logger-factory-method.js.map +1 -0
- package/dist/src/logging/logger.d.ts +15 -0
- package/dist/src/logging/logger.d.ts.map +1 -0
- package/dist/src/logging/logger.js +2 -0
- package/dist/src/logging/logger.js.map +1 -0
- package/dist/src/plugin/contexts.d.ts +19 -0
- package/dist/src/plugin/contexts.d.ts.map +1 -0
- package/dist/src/plugin/contexts.js +2 -0
- package/dist/src/plugin/contexts.js.map +1 -0
- package/dist/src/plugin/index.d.ts +7 -0
- package/dist/src/plugin/index.d.ts.map +1 -0
- package/dist/src/plugin/index.js +6 -0
- package/dist/src/plugin/index.js.map +1 -0
- package/dist/src/plugin/plugin-kind.d.ts +10 -0
- package/dist/src/plugin/plugin-kind.d.ts.map +1 -0
- package/dist/src/plugin/plugin-kind.js +11 -0
- package/dist/src/plugin/plugin-kind.js.map +1 -0
- package/dist/src/plugin/plugins.d.ts +79 -0
- package/dist/src/plugin/plugins.d.ts.map +1 -0
- package/dist/src/plugin/plugins.js +41 -0
- package/dist/src/plugin/plugins.js.map +1 -0
- package/dist/src/plugin/scope.d.ts +5 -0
- package/dist/src/plugin/scope.d.ts.map +1 -0
- package/dist/src/plugin/scope.js +7 -0
- package/dist/src/plugin/scope.js.map +1 -0
- package/dist/src/plugin/tokens.d.ts +22 -0
- package/dist/src/plugin/tokens.d.ts.map +1 -0
- package/dist/src/plugin/tokens.js +33 -0
- package/dist/src/plugin/tokens.js.map +1 -0
- package/dist/src/report/dry-run-completed-event.d.ts +18 -0
- package/dist/src/report/dry-run-completed-event.d.ts.map +1 -0
- package/dist/src/report/dry-run-completed-event.js +2 -0
- package/dist/src/report/dry-run-completed-event.js.map +1 -0
- package/dist/src/report/index.d.ts +4 -0
- package/dist/src/report/index.d.ts.map +1 -0
- package/dist/src/report/index.js +2 -0
- package/dist/src/report/index.js.map +1 -0
- package/dist/src/report/mutation-testing-plan-ready-event.d.ts +5 -0
- package/dist/src/report/mutation-testing-plan-ready-event.d.ts.map +1 -0
- package/dist/src/report/mutation-testing-plan-ready-event.js +2 -0
- package/dist/src/report/mutation-testing-plan-ready-event.js.map +1 -0
- package/dist/src/report/reporter.d.ts +38 -0
- package/dist/src/report/reporter.d.ts.map +1 -0
- package/dist/src/report/reporter.js +2 -0
- package/dist/src/report/reporter.js.map +1 -0
- package/dist/src/test-runner/dry-run-result.d.ts +36 -0
- package/dist/src/test-runner/dry-run-result.d.ts.map +1 -0
- package/dist/src/test-runner/dry-run-result.js +2 -0
- package/dist/src/test-runner/dry-run-result.js.map +1 -0
- package/dist/src/test-runner/dry-run-status.d.ts +15 -0
- package/dist/src/test-runner/dry-run-status.d.ts.map +1 -0
- package/dist/src/test-runner/dry-run-status.js +16 -0
- package/dist/src/test-runner/dry-run-status.js.map +1 -0
- package/dist/src/test-runner/index.d.ts +10 -0
- package/dist/src/test-runner/index.d.ts.map +1 -0
- package/dist/src/test-runner/index.js +10 -0
- package/dist/src/test-runner/index.js.map +1 -0
- package/dist/src/test-runner/mutant-run-result.d.ts +57 -0
- package/dist/src/test-runner/mutant-run-result.d.ts.map +1 -0
- package/dist/src/test-runner/mutant-run-result.js +8 -0
- package/dist/src/test-runner/mutant-run-result.js.map +1 -0
- package/dist/src/test-runner/run-options.d.ts +50 -0
- package/dist/src/test-runner/run-options.d.ts.map +1 -0
- package/dist/src/test-runner/run-options.js +2 -0
- package/dist/src/test-runner/run-options.js.map +1 -0
- package/dist/src/test-runner/run-result-helpers.d.ts +5 -0
- package/dist/src/test-runner/run-result-helpers.d.ts.map +1 -0
- package/dist/src/test-runner/run-result-helpers.js +70 -0
- package/dist/src/test-runner/run-result-helpers.js.map +1 -0
- package/dist/src/test-runner/test-result.d.ts +39 -0
- package/dist/src/test-runner/test-result.d.ts.map +1 -0
- package/dist/src/test-runner/test-result.js +2 -0
- package/dist/src/test-runner/test-result.js.map +1 -0
- package/dist/src/test-runner/test-runner-capabilities.d.ts +12 -0
- package/dist/src/test-runner/test-runner-capabilities.d.ts.map +1 -0
- package/dist/src/test-runner/test-runner-capabilities.js +2 -0
- package/dist/src/test-runner/test-runner-capabilities.js.map +1 -0
- package/dist/src/test-runner/test-runner.d.ts +12 -0
- package/dist/src/test-runner/test-runner.d.ts.map +1 -0
- package/dist/src/test-runner/test-runner.js +2 -0
- package/dist/src/test-runner/test-runner.js.map +1 -0
- package/dist/src/test-runner/test-status.d.ts +18 -0
- package/dist/src/test-runner/test-status.d.ts.map +1 -0
- package/dist/src/test-runner/test-status.js +19 -0
- package/dist/src/test-runner/test-status.js.map +1 -0
- package/dist/src-generated/stryker-core.d.ts +298 -0
- package/dist/src-generated/stryker-core.d.ts.map +1 -0
- package/dist/src-generated/stryker-core.js +7 -0
- package/dist/src-generated/stryker-core.js.map +1 -0
- package/package.json +68 -0
- package/src/check/check-result.ts +12 -0
- package/src/check/check-status.ts +4 -0
- package/src/check/checker.ts +22 -0
- package/src/check/index.ts +3 -0
- package/src/check/mutant-status.ts +10 -0
- package/src/core/file-description.ts +15 -0
- package/src/core/index.ts +16 -0
- package/src/core/instrument.ts +26 -0
- package/src/core/location.ts +9 -0
- package/src/core/mutant-coverage.ts +11 -0
- package/src/core/mutant-test-plan.ts +56 -0
- package/src/core/mutant.ts +54 -0
- package/src/core/mutation-range.ts +16 -0
- package/src/core/partial-stryker-options.ts +14 -0
- package/src/core/position.ts +8 -0
- package/src/core/report-types.ts +6 -0
- package/src/core/stryker-options-schema.ts +11 -0
- package/src/ignore/ignorer.ts +8 -0
- package/src/ignore/index.ts +1 -0
- package/src/logging/index.ts +2 -0
- package/src/logging/logger-factory-method.ts +10 -0
- package/src/logging/logger.ts +15 -0
- package/src/plugin/contexts.ts +21 -0
- package/src/plugin/index.ts +12 -0
- package/src/plugin/plugin-kind.ts +9 -0
- package/src/plugin/plugins.ts +155 -0
- package/src/plugin/scope.ts +6 -0
- package/src/plugin/tokens.ts +35 -0
- package/src/report/dry-run-completed-event.ts +22 -0
- package/src/report/index.ts +6 -0
- package/src/report/mutation-testing-plan-ready-event.ts +5 -0
- package/src/report/reporter.ts +47 -0
- package/src/test-runner/dry-run-result.ts +45 -0
- package/src/test-runner/dry-run-status.ts +14 -0
- package/src/test-runner/index.ts +9 -0
- package/src/test-runner/mutant-run-result.ts +69 -0
- package/src/test-runner/run-options.ts +53 -0
- package/src/test-runner/run-result-helpers.ts +90 -0
- package/src/test-runner/test-result.ts +49 -0
- package/src/test-runner/test-runner-capabilities.ts +11 -0
- package/src/test-runner/test-runner.ts +12 -0
- package/src/test-runner/test-status.ts +17 -0
- package/src-generated/stryker-core.ts +300 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { MutationTestMetricsResult } from 'mutation-testing-metrics';
|
|
2
|
+
|
|
3
|
+
import { MutantResult, schema } from '../core/index.js';
|
|
4
|
+
|
|
5
|
+
import { DryRunCompletedEvent } from './dry-run-completed-event.js';
|
|
6
|
+
import { MutationTestingPlanReadyEvent } from './mutation-testing-plan-ready-event.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents a reporter which can report during or after a Stryker run
|
|
10
|
+
*/
|
|
11
|
+
export interface Reporter {
|
|
12
|
+
/**
|
|
13
|
+
* An event emitted when the dry run completed successfully.
|
|
14
|
+
* @param event The dry run completed event
|
|
15
|
+
*/
|
|
16
|
+
onDryRunCompleted?(event: DryRunCompletedEvent): void;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An event emitted when the mutant test plan is calculated.
|
|
20
|
+
* @param event The mutant test plan ready event
|
|
21
|
+
*/
|
|
22
|
+
onMutationTestingPlanReady?(event: MutationTestingPlanReadyEvent): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Called when a mutant was tested
|
|
26
|
+
* @param result The immutable result
|
|
27
|
+
*/
|
|
28
|
+
onMutantTested?(result: Readonly<MutantResult>): void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Called when mutation testing is done
|
|
32
|
+
* @param report the mutation test result that is valid according to the mutation-testing-report-schema (json schema)
|
|
33
|
+
* @see https://github.com/stryker-mutator/mutation-testing-elements/blob/master/packages/report-schema/src/mutation-testing-report-schema.json
|
|
34
|
+
*/
|
|
35
|
+
onMutationTestReportReady?(
|
|
36
|
+
report: Readonly<schema.MutationTestResult>,
|
|
37
|
+
metrics: Readonly<MutationTestMetricsResult>,
|
|
38
|
+
): void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Called when stryker wants to quit
|
|
42
|
+
* Gives a reporter the ability to finish up any async tasks
|
|
43
|
+
* Stryker will not close until the promise is either resolved or rejected.
|
|
44
|
+
* @return a promise which will resolve when the reporter is done reporting
|
|
45
|
+
*/
|
|
46
|
+
wrapUp?(): Promise<void> | void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { MutantCoverage } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
import { DryRunStatus } from './dry-run-status.js';
|
|
4
|
+
import { TestResult } from './test-result.js';
|
|
5
|
+
|
|
6
|
+
export type DryRunResult =
|
|
7
|
+
| CompleteDryRunResult
|
|
8
|
+
| ErrorDryRunResult
|
|
9
|
+
| TimeoutDryRunResult;
|
|
10
|
+
|
|
11
|
+
export interface CompleteDryRunResult {
|
|
12
|
+
/**
|
|
13
|
+
* The individual test results.
|
|
14
|
+
*/
|
|
15
|
+
tests: TestResult[];
|
|
16
|
+
|
|
17
|
+
mutantCoverage?: MutantCoverage;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The status of the run
|
|
21
|
+
*/
|
|
22
|
+
status: DryRunStatus.Complete;
|
|
23
|
+
}
|
|
24
|
+
export interface TimeoutDryRunResult {
|
|
25
|
+
/**
|
|
26
|
+
* The status of the run
|
|
27
|
+
*/
|
|
28
|
+
status: DryRunStatus.Timeout;
|
|
29
|
+
/**
|
|
30
|
+
* An optional reason for the timeout
|
|
31
|
+
*/
|
|
32
|
+
reason?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ErrorDryRunResult {
|
|
36
|
+
/**
|
|
37
|
+
* The status of the run
|
|
38
|
+
*/
|
|
39
|
+
status: DryRunStatus.Error;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* If `state` is `error`, this collection should contain the error messages
|
|
43
|
+
*/
|
|
44
|
+
errorMessage: string;
|
|
45
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export enum DryRunStatus {
|
|
2
|
+
/**
|
|
3
|
+
* Indicates that a test run is completed with failed or succeeded tests
|
|
4
|
+
*/
|
|
5
|
+
Complete = 'complete',
|
|
6
|
+
/**
|
|
7
|
+
* Indicates that a test run cut off early with an error
|
|
8
|
+
*/
|
|
9
|
+
Error = 'error',
|
|
10
|
+
/**
|
|
11
|
+
* Indicates that a test run timed out
|
|
12
|
+
*/
|
|
13
|
+
Timeout = 'timeout',
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './test-result.js';
|
|
2
|
+
export * from './test-runner.js';
|
|
3
|
+
export * from './test-status.js';
|
|
4
|
+
export * from './dry-run-result.js';
|
|
5
|
+
export * from './run-options.js';
|
|
6
|
+
export * from './mutant-run-result.js';
|
|
7
|
+
export * from './dry-run-status.js';
|
|
8
|
+
export * from './run-result-helpers.js';
|
|
9
|
+
export * from './test-runner-capabilities.js';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { TestStatus } from './test-status.js';
|
|
2
|
+
|
|
3
|
+
export enum MutantRunStatus {
|
|
4
|
+
Killed = 'killed',
|
|
5
|
+
Survived = 'survived',
|
|
6
|
+
Timeout = 'timeout',
|
|
7
|
+
Error = 'error',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type MutantRunResult =
|
|
11
|
+
| ErrorMutantRunResult
|
|
12
|
+
| KilledMutantRunResult
|
|
13
|
+
| SurvivedMutantRunResult
|
|
14
|
+
| TimeoutMutantRunResult;
|
|
15
|
+
|
|
16
|
+
export interface TimeoutMutantRunResult {
|
|
17
|
+
status: MutantRunStatus.Timeout;
|
|
18
|
+
/**
|
|
19
|
+
* An optional reason for the timeout
|
|
20
|
+
*/
|
|
21
|
+
reason?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface KilledMutantRunResult {
|
|
25
|
+
status: MutantRunStatus.Killed;
|
|
26
|
+
/**
|
|
27
|
+
* An array with the ids of the tests that killed this mutant
|
|
28
|
+
*/
|
|
29
|
+
killedBy: string[];
|
|
30
|
+
/**
|
|
31
|
+
* The failure message that was reported by first the test
|
|
32
|
+
*/
|
|
33
|
+
failureMessage: string;
|
|
34
|
+
/**
|
|
35
|
+
* The number of total tests ran in this test run.
|
|
36
|
+
*/
|
|
37
|
+
nrOfTests: number;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Optional per-test timing details for tests executed in this mutant run.
|
|
41
|
+
*/
|
|
42
|
+
executedTests?: MutantRunExecutedTest[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SurvivedMutantRunResult {
|
|
46
|
+
status: MutantRunStatus.Survived;
|
|
47
|
+
/**
|
|
48
|
+
* The number of total tests ran in this test run.
|
|
49
|
+
*/
|
|
50
|
+
nrOfTests: number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Optional per-test timing details for tests executed in this mutant run.
|
|
54
|
+
*/
|
|
55
|
+
executedTests?: MutantRunExecutedTest[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ErrorMutantRunResult {
|
|
59
|
+
status: MutantRunStatus.Error;
|
|
60
|
+
errorMessage: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface MutantRunExecutedTest {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
status: TestStatus;
|
|
67
|
+
timeSpentMs: number;
|
|
68
|
+
fileName?: string;
|
|
69
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Mutant, CoverageAnalysis } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
export interface RunOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The amount of time (in milliseconds) the TestRunner has to complete the test run before a timeout occurs.
|
|
6
|
+
*/
|
|
7
|
+
timeout: number;
|
|
8
|
+
/**
|
|
9
|
+
* Filled from disableBail in config
|
|
10
|
+
*/
|
|
11
|
+
disableBail: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface DryRunOptions extends RunOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Indicates whether or not mutant coverage should be collected.
|
|
17
|
+
*/
|
|
18
|
+
coverageAnalysis: CoverageAnalysis;
|
|
19
|
+
/**
|
|
20
|
+
* Files with mutants to run tests for.
|
|
21
|
+
*/
|
|
22
|
+
files?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* If provided, only tests from these files will be executed.
|
|
25
|
+
*/
|
|
26
|
+
testFiles?: string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type MutantActivation = 'runtime' | 'static';
|
|
30
|
+
|
|
31
|
+
export interface MutantRunOptions extends RunOptions {
|
|
32
|
+
testFilter?: string[];
|
|
33
|
+
hitLimit?: number;
|
|
34
|
+
activeMutant: Mutant;
|
|
35
|
+
/**
|
|
36
|
+
* The name of file inside the sandbox in which the mutant resides
|
|
37
|
+
*/
|
|
38
|
+
sandboxFileName: string;
|
|
39
|
+
/**
|
|
40
|
+
* Determine when to active the mutant.
|
|
41
|
+
* - 'runtime'. The test environment should first load all tests and sut files before activating the mutant. Mutant is only active during runtime.
|
|
42
|
+
* - 'static'. The test environment should load _while the mutant is active_. Mutant may be active during the entire lifetime of the process.
|
|
43
|
+
* See https://github.com/stryker-mutator/stryker-js/issues/3442 for more details
|
|
44
|
+
*/
|
|
45
|
+
mutantActivation: MutantActivation;
|
|
46
|
+
/**
|
|
47
|
+
* Determines whether or not the test environment should be reloaded.
|
|
48
|
+
* This is necessary when testing static mutants, where the mutant is only executed when the test environment is loaded.
|
|
49
|
+
* A test runner might be unable to reload the test environment, i.e. when the files were loaded via `import` in nodejs.
|
|
50
|
+
* In which case the test runner should report `reloadEnvironment: false` in it's capabilities.
|
|
51
|
+
*/
|
|
52
|
+
reloadEnvironment: boolean;
|
|
53
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { TestStatus } from './test-status.js';
|
|
2
|
+
import { DryRunResult, TimeoutDryRunResult } from './dry-run-result.js';
|
|
3
|
+
import { MutantRunResult, MutantRunStatus } from './mutant-run-result.js';
|
|
4
|
+
import { DryRunStatus } from './dry-run-status.js';
|
|
5
|
+
import { FailedTestResult } from './test-result.js';
|
|
6
|
+
|
|
7
|
+
export function determineHitLimitReached(
|
|
8
|
+
hitCount: number | undefined,
|
|
9
|
+
hitLimit: number | undefined,
|
|
10
|
+
): TimeoutDryRunResult | undefined {
|
|
11
|
+
if (hitCount !== undefined && hitLimit !== undefined && hitCount > hitLimit) {
|
|
12
|
+
return {
|
|
13
|
+
status: DryRunStatus.Timeout,
|
|
14
|
+
reason: `Hit limit reached (${hitCount}/${hitLimit})`,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function toMutantRunResult(
|
|
21
|
+
dryRunResult: DryRunResult,
|
|
22
|
+
reportAllKillers = true,
|
|
23
|
+
includeExecutedTests = process.env.STRYKER_MUTATION_TEST_TIMINGS === '1',
|
|
24
|
+
): MutantRunResult {
|
|
25
|
+
switch (dryRunResult.status) {
|
|
26
|
+
case DryRunStatus.Complete: {
|
|
27
|
+
const failedTests = dryRunResult.tests.filter<FailedTestResult>(
|
|
28
|
+
(test): test is FailedTestResult => test.status === TestStatus.Failed,
|
|
29
|
+
);
|
|
30
|
+
const nrOfTests = dryRunResult.tests.filter(
|
|
31
|
+
(test) => test.status !== TestStatus.Skipped,
|
|
32
|
+
).length;
|
|
33
|
+
const executedTests = includeExecutedTests
|
|
34
|
+
? dryRunResult.tests
|
|
35
|
+
.filter((test) => test.status !== TestStatus.Skipped)
|
|
36
|
+
.map((test) => ({
|
|
37
|
+
id: test.id,
|
|
38
|
+
name: test.name,
|
|
39
|
+
status: test.status,
|
|
40
|
+
timeSpentMs: test.timeSpentMs,
|
|
41
|
+
fileName: test.fileName,
|
|
42
|
+
}))
|
|
43
|
+
: undefined;
|
|
44
|
+
const maxExecutedTests = Number.parseInt(
|
|
45
|
+
process.env.STRYKER_MUTATION_TEST_TIMINGS_MAX_TESTS ?? '',
|
|
46
|
+
10,
|
|
47
|
+
);
|
|
48
|
+
const boundedExecutedTests =
|
|
49
|
+
executedTests &&
|
|
50
|
+
Number.isFinite(maxExecutedTests) &&
|
|
51
|
+
maxExecutedTests > 0
|
|
52
|
+
? executedTests.slice(0, maxExecutedTests)
|
|
53
|
+
: executedTests;
|
|
54
|
+
|
|
55
|
+
if (failedTests.length > 0) {
|
|
56
|
+
const killedResult = {
|
|
57
|
+
status: MutantRunStatus.Killed as const,
|
|
58
|
+
failureMessage: failedTests[0].failureMessage,
|
|
59
|
+
killedBy: reportAllKillers
|
|
60
|
+
? failedTests.map<string>((test) => test.id)
|
|
61
|
+
: [failedTests[0].id],
|
|
62
|
+
nrOfTests,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return boundedExecutedTests
|
|
66
|
+
? { ...killedResult, executedTests: boundedExecutedTests }
|
|
67
|
+
: killedResult;
|
|
68
|
+
} else {
|
|
69
|
+
const survivedResult = {
|
|
70
|
+
status: MutantRunStatus.Survived as const,
|
|
71
|
+
nrOfTests,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return boundedExecutedTests
|
|
75
|
+
? { ...survivedResult, executedTests: boundedExecutedTests }
|
|
76
|
+
: survivedResult;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
case DryRunStatus.Error:
|
|
80
|
+
return {
|
|
81
|
+
status: MutantRunStatus.Error,
|
|
82
|
+
errorMessage: dryRunResult.errorMessage,
|
|
83
|
+
};
|
|
84
|
+
case DryRunStatus.Timeout:
|
|
85
|
+
return {
|
|
86
|
+
status: MutantRunStatus.Timeout,
|
|
87
|
+
reason: dryRunResult.reason,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Position } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
import { TestStatus } from './test-status.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Indicates the result of a single test
|
|
7
|
+
*/
|
|
8
|
+
export interface BaseTestResult {
|
|
9
|
+
/**
|
|
10
|
+
* The id of this test. Can be the name if the test runner doesn't have an 'id'
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* The full human readable name of the test
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* The time it took to run the test
|
|
19
|
+
*/
|
|
20
|
+
timeSpentMs: number;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The file where this test was defined in (if known)
|
|
24
|
+
*/
|
|
25
|
+
fileName?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The position of the test (if known)
|
|
29
|
+
*/
|
|
30
|
+
startPosition?: Position;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface FailedTestResult extends BaseTestResult {
|
|
34
|
+
status: TestStatus.Failed;
|
|
35
|
+
failureMessage: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SkippedTestResult extends BaseTestResult {
|
|
39
|
+
status: TestStatus.Skipped;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface SuccessTestResult extends BaseTestResult {
|
|
43
|
+
status: TestStatus.Success;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type TestResult =
|
|
47
|
+
| FailedTestResult
|
|
48
|
+
| SkippedTestResult
|
|
49
|
+
| SuccessTestResult;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the capabilities of a test runner.
|
|
3
|
+
*/
|
|
4
|
+
export interface TestRunnerCapabilities {
|
|
5
|
+
/**
|
|
6
|
+
* When true, the test runner is capable of reloading the test environment. Otherwise false.
|
|
7
|
+
* Reloading means creating a new nodejs process, or reloading the browser.
|
|
8
|
+
* When true, the test runner should reload the test environment when `reloadEnvironment` is present in the run options.
|
|
9
|
+
*/
|
|
10
|
+
reloadEnvironment: boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DryRunOptions, MutantRunOptions } from './run-options.js';
|
|
2
|
+
import { DryRunResult } from './dry-run-result.js';
|
|
3
|
+
import { MutantRunResult } from './mutant-run-result.js';
|
|
4
|
+
import { TestRunnerCapabilities } from './test-runner-capabilities.js';
|
|
5
|
+
|
|
6
|
+
export interface TestRunner {
|
|
7
|
+
capabilities(): Promise<TestRunnerCapabilities> | TestRunnerCapabilities;
|
|
8
|
+
init?(): Promise<void>;
|
|
9
|
+
dryRun(options: DryRunOptions): Promise<DryRunResult>;
|
|
10
|
+
mutantRun(options: MutantRunOptions): Promise<MutantRunResult>;
|
|
11
|
+
dispose?(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indicates what the result of a single test was.
|
|
3
|
+
*/
|
|
4
|
+
export enum TestStatus {
|
|
5
|
+
/**
|
|
6
|
+
* The test succeeded
|
|
7
|
+
*/
|
|
8
|
+
Success,
|
|
9
|
+
/**
|
|
10
|
+
* The test failed
|
|
11
|
+
*/
|
|
12
|
+
Failed,
|
|
13
|
+
/**
|
|
14
|
+
* The test was skipped (not executed)
|
|
15
|
+
*/
|
|
16
|
+
Skipped,
|
|
17
|
+
}
|