@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.
Files changed (220) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +25 -0
  3. package/core.d.ts +3 -0
  4. package/dist/schema/stryker-core.json +567 -0
  5. package/dist/src/check/check-result.d.ts +10 -0
  6. package/dist/src/check/check-result.d.ts.map +1 -0
  7. package/dist/src/check/check-result.js +2 -0
  8. package/dist/src/check/check-result.js.map +1 -0
  9. package/dist/src/check/check-status.d.ts +5 -0
  10. package/dist/src/check/check-status.d.ts.map +1 -0
  11. package/dist/src/check/check-status.js +6 -0
  12. package/dist/src/check/check-status.js.map +1 -0
  13. package/dist/src/check/checker.d.ts +19 -0
  14. package/dist/src/check/checker.d.ts.map +1 -0
  15. package/dist/src/check/checker.js +2 -0
  16. package/dist/src/check/checker.js.map +1 -0
  17. package/dist/src/check/index.d.ts +4 -0
  18. package/dist/src/check/index.d.ts.map +1 -0
  19. package/dist/src/check/index.js +4 -0
  20. package/dist/src/check/index.js.map +1 -0
  21. package/dist/src/check/mutant-status.d.ts +11 -0
  22. package/dist/src/check/mutant-status.d.ts.map +1 -0
  23. package/dist/src/check/mutant-status.js +12 -0
  24. package/dist/src/check/mutant-status.js.map +1 -0
  25. package/dist/src/core/file-description.d.ts +13 -0
  26. package/dist/src/core/file-description.d.ts.map +1 -0
  27. package/dist/src/core/file-description.js +2 -0
  28. package/dist/src/core/file-description.js.map +1 -0
  29. package/dist/src/core/index.d.ts +17 -0
  30. package/dist/src/core/index.d.ts.map +1 -0
  31. package/dist/src/core/index.js +15 -0
  32. package/dist/src/core/index.js.map +1 -0
  33. package/dist/src/core/instrument.d.ts +21 -0
  34. package/dist/src/core/instrument.d.ts.map +1 -0
  35. package/dist/src/core/instrument.js +16 -0
  36. package/dist/src/core/instrument.js.map +1 -0
  37. package/dist/src/core/location.d.ts +9 -0
  38. package/dist/src/core/location.d.ts.map +1 -0
  39. package/dist/src/core/location.js +2 -0
  40. package/dist/src/core/location.js.map +1 -0
  41. package/dist/src/core/mutant-coverage.d.ts +10 -0
  42. package/dist/src/core/mutant-coverage.d.ts.map +1 -0
  43. package/dist/src/core/mutant-coverage.js +2 -0
  44. package/dist/src/core/mutant-coverage.js.map +1 -0
  45. package/dist/src/core/mutant-test-plan.d.ts +52 -0
  46. package/dist/src/core/mutant-test-plan.d.ts.map +1 -0
  47. package/dist/src/core/mutant-test-plan.js +15 -0
  48. package/dist/src/core/mutant-test-plan.js.map +1 -0
  49. package/dist/src/core/mutant.d.ts +36 -0
  50. package/dist/src/core/mutant.d.ts.map +1 -0
  51. package/dist/src/core/mutant.js +2 -0
  52. package/dist/src/core/mutant.js.map +1 -0
  53. package/dist/src/core/mutation-range.d.ts +15 -0
  54. package/dist/src/core/mutation-range.d.ts.map +1 -0
  55. package/dist/src/core/mutation-range.js +2 -0
  56. package/dist/src/core/mutation-range.js.map +1 -0
  57. package/dist/src/core/partial-stryker-options.d.ts +12 -0
  58. package/dist/src/core/partial-stryker-options.d.ts.map +1 -0
  59. package/dist/src/core/partial-stryker-options.js +2 -0
  60. package/dist/src/core/partial-stryker-options.js.map +1 -0
  61. package/dist/src/core/position.d.ts +9 -0
  62. package/dist/src/core/position.d.ts.map +1 -0
  63. package/dist/src/core/position.js +2 -0
  64. package/dist/src/core/position.js.map +1 -0
  65. package/dist/src/core/report-types.d.ts +3 -0
  66. package/dist/src/core/report-types.d.ts.map +1 -0
  67. package/dist/src/core/report-types.js +5 -0
  68. package/dist/src/core/report-types.js.map +1 -0
  69. package/dist/src/core/stryker-options-schema.d.ts +3 -0
  70. package/dist/src/core/stryker-options-schema.d.ts.map +1 -0
  71. package/dist/src/core/stryker-options-schema.js +5 -0
  72. package/dist/src/core/stryker-options-schema.js.map +1 -0
  73. package/dist/src/ignore/ignorer.d.ts +6 -0
  74. package/dist/src/ignore/ignorer.d.ts.map +1 -0
  75. package/dist/src/ignore/ignorer.js +2 -0
  76. package/dist/src/ignore/ignorer.js.map +1 -0
  77. package/dist/src/ignore/index.d.ts +2 -0
  78. package/dist/src/ignore/index.d.ts.map +1 -0
  79. package/dist/src/ignore/index.js +2 -0
  80. package/dist/src/ignore/index.js.map +1 -0
  81. package/dist/src/logging/index.d.ts +3 -0
  82. package/dist/src/logging/index.d.ts.map +1 -0
  83. package/dist/src/logging/index.js +2 -0
  84. package/dist/src/logging/index.js.map +1 -0
  85. package/dist/src/logging/logger-factory-method.d.ts +10 -0
  86. package/dist/src/logging/logger-factory-method.d.ts.map +1 -0
  87. package/dist/src/logging/logger-factory-method.js +2 -0
  88. package/dist/src/logging/logger-factory-method.js.map +1 -0
  89. package/dist/src/logging/logger.d.ts +15 -0
  90. package/dist/src/logging/logger.d.ts.map +1 -0
  91. package/dist/src/logging/logger.js +2 -0
  92. package/dist/src/logging/logger.js.map +1 -0
  93. package/dist/src/plugin/contexts.d.ts +19 -0
  94. package/dist/src/plugin/contexts.d.ts.map +1 -0
  95. package/dist/src/plugin/contexts.js +2 -0
  96. package/dist/src/plugin/contexts.js.map +1 -0
  97. package/dist/src/plugin/index.d.ts +7 -0
  98. package/dist/src/plugin/index.d.ts.map +1 -0
  99. package/dist/src/plugin/index.js +6 -0
  100. package/dist/src/plugin/index.js.map +1 -0
  101. package/dist/src/plugin/plugin-kind.d.ts +10 -0
  102. package/dist/src/plugin/plugin-kind.d.ts.map +1 -0
  103. package/dist/src/plugin/plugin-kind.js +11 -0
  104. package/dist/src/plugin/plugin-kind.js.map +1 -0
  105. package/dist/src/plugin/plugins.d.ts +79 -0
  106. package/dist/src/plugin/plugins.d.ts.map +1 -0
  107. package/dist/src/plugin/plugins.js +41 -0
  108. package/dist/src/plugin/plugins.js.map +1 -0
  109. package/dist/src/plugin/scope.d.ts +5 -0
  110. package/dist/src/plugin/scope.d.ts.map +1 -0
  111. package/dist/src/plugin/scope.js +7 -0
  112. package/dist/src/plugin/scope.js.map +1 -0
  113. package/dist/src/plugin/tokens.d.ts +22 -0
  114. package/dist/src/plugin/tokens.d.ts.map +1 -0
  115. package/dist/src/plugin/tokens.js +33 -0
  116. package/dist/src/plugin/tokens.js.map +1 -0
  117. package/dist/src/report/dry-run-completed-event.d.ts +18 -0
  118. package/dist/src/report/dry-run-completed-event.d.ts.map +1 -0
  119. package/dist/src/report/dry-run-completed-event.js +2 -0
  120. package/dist/src/report/dry-run-completed-event.js.map +1 -0
  121. package/dist/src/report/index.d.ts +4 -0
  122. package/dist/src/report/index.d.ts.map +1 -0
  123. package/dist/src/report/index.js +2 -0
  124. package/dist/src/report/index.js.map +1 -0
  125. package/dist/src/report/mutation-testing-plan-ready-event.d.ts +5 -0
  126. package/dist/src/report/mutation-testing-plan-ready-event.d.ts.map +1 -0
  127. package/dist/src/report/mutation-testing-plan-ready-event.js +2 -0
  128. package/dist/src/report/mutation-testing-plan-ready-event.js.map +1 -0
  129. package/dist/src/report/reporter.d.ts +38 -0
  130. package/dist/src/report/reporter.d.ts.map +1 -0
  131. package/dist/src/report/reporter.js +2 -0
  132. package/dist/src/report/reporter.js.map +1 -0
  133. package/dist/src/test-runner/dry-run-result.d.ts +36 -0
  134. package/dist/src/test-runner/dry-run-result.d.ts.map +1 -0
  135. package/dist/src/test-runner/dry-run-result.js +2 -0
  136. package/dist/src/test-runner/dry-run-result.js.map +1 -0
  137. package/dist/src/test-runner/dry-run-status.d.ts +15 -0
  138. package/dist/src/test-runner/dry-run-status.d.ts.map +1 -0
  139. package/dist/src/test-runner/dry-run-status.js +16 -0
  140. package/dist/src/test-runner/dry-run-status.js.map +1 -0
  141. package/dist/src/test-runner/index.d.ts +10 -0
  142. package/dist/src/test-runner/index.d.ts.map +1 -0
  143. package/dist/src/test-runner/index.js +10 -0
  144. package/dist/src/test-runner/index.js.map +1 -0
  145. package/dist/src/test-runner/mutant-run-result.d.ts +57 -0
  146. package/dist/src/test-runner/mutant-run-result.d.ts.map +1 -0
  147. package/dist/src/test-runner/mutant-run-result.js +8 -0
  148. package/dist/src/test-runner/mutant-run-result.js.map +1 -0
  149. package/dist/src/test-runner/run-options.d.ts +50 -0
  150. package/dist/src/test-runner/run-options.d.ts.map +1 -0
  151. package/dist/src/test-runner/run-options.js +2 -0
  152. package/dist/src/test-runner/run-options.js.map +1 -0
  153. package/dist/src/test-runner/run-result-helpers.d.ts +5 -0
  154. package/dist/src/test-runner/run-result-helpers.d.ts.map +1 -0
  155. package/dist/src/test-runner/run-result-helpers.js +70 -0
  156. package/dist/src/test-runner/run-result-helpers.js.map +1 -0
  157. package/dist/src/test-runner/test-result.d.ts +39 -0
  158. package/dist/src/test-runner/test-result.d.ts.map +1 -0
  159. package/dist/src/test-runner/test-result.js +2 -0
  160. package/dist/src/test-runner/test-result.js.map +1 -0
  161. package/dist/src/test-runner/test-runner-capabilities.d.ts +12 -0
  162. package/dist/src/test-runner/test-runner-capabilities.d.ts.map +1 -0
  163. package/dist/src/test-runner/test-runner-capabilities.js +2 -0
  164. package/dist/src/test-runner/test-runner-capabilities.js.map +1 -0
  165. package/dist/src/test-runner/test-runner.d.ts +12 -0
  166. package/dist/src/test-runner/test-runner.d.ts.map +1 -0
  167. package/dist/src/test-runner/test-runner.js +2 -0
  168. package/dist/src/test-runner/test-runner.js.map +1 -0
  169. package/dist/src/test-runner/test-status.d.ts +18 -0
  170. package/dist/src/test-runner/test-status.d.ts.map +1 -0
  171. package/dist/src/test-runner/test-status.js +19 -0
  172. package/dist/src/test-runner/test-status.js.map +1 -0
  173. package/dist/src-generated/stryker-core.d.ts +298 -0
  174. package/dist/src-generated/stryker-core.d.ts.map +1 -0
  175. package/dist/src-generated/stryker-core.js +7 -0
  176. package/dist/src-generated/stryker-core.js.map +1 -0
  177. package/package.json +68 -0
  178. package/src/check/check-result.ts +12 -0
  179. package/src/check/check-status.ts +4 -0
  180. package/src/check/checker.ts +22 -0
  181. package/src/check/index.ts +3 -0
  182. package/src/check/mutant-status.ts +10 -0
  183. package/src/core/file-description.ts +15 -0
  184. package/src/core/index.ts +16 -0
  185. package/src/core/instrument.ts +26 -0
  186. package/src/core/location.ts +9 -0
  187. package/src/core/mutant-coverage.ts +11 -0
  188. package/src/core/mutant-test-plan.ts +56 -0
  189. package/src/core/mutant.ts +54 -0
  190. package/src/core/mutation-range.ts +16 -0
  191. package/src/core/partial-stryker-options.ts +14 -0
  192. package/src/core/position.ts +8 -0
  193. package/src/core/report-types.ts +6 -0
  194. package/src/core/stryker-options-schema.ts +11 -0
  195. package/src/ignore/ignorer.ts +8 -0
  196. package/src/ignore/index.ts +1 -0
  197. package/src/logging/index.ts +2 -0
  198. package/src/logging/logger-factory-method.ts +10 -0
  199. package/src/logging/logger.ts +15 -0
  200. package/src/plugin/contexts.ts +21 -0
  201. package/src/plugin/index.ts +12 -0
  202. package/src/plugin/plugin-kind.ts +9 -0
  203. package/src/plugin/plugins.ts +155 -0
  204. package/src/plugin/scope.ts +6 -0
  205. package/src/plugin/tokens.ts +35 -0
  206. package/src/report/dry-run-completed-event.ts +22 -0
  207. package/src/report/index.ts +6 -0
  208. package/src/report/mutation-testing-plan-ready-event.ts +5 -0
  209. package/src/report/reporter.ts +47 -0
  210. package/src/test-runner/dry-run-result.ts +45 -0
  211. package/src/test-runner/dry-run-status.ts +14 -0
  212. package/src/test-runner/index.ts +9 -0
  213. package/src/test-runner/mutant-run-result.ts +69 -0
  214. package/src/test-runner/run-options.ts +53 -0
  215. package/src/test-runner/run-result-helpers.ts +90 -0
  216. package/src/test-runner/test-result.ts +49 -0
  217. package/src/test-runner/test-runner-capabilities.ts +11 -0
  218. package/src/test-runner/test-runner.ts +12 -0
  219. package/src/test-runner/test-status.ts +17 -0
  220. 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
+ }