@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,4 @@
1
+ export enum CheckStatus {
2
+ Passed = 'passed',
3
+ CompileError = 'compileError',
4
+ }
@@ -0,0 +1,22 @@
1
+ import { Mutant } from '../core/index.js';
2
+
3
+ import { CheckResult } from './check-result.js';
4
+
5
+ export interface Checker {
6
+ init(): Promise<void>;
7
+
8
+ /**
9
+ * Check a mutant group.
10
+ * @param mutants A group of mutants to check
11
+ * @returns key-value pairs of mutant ids with the check results
12
+ */
13
+ check(mutants: Mutant[]): Promise<Record<string, CheckResult>>;
14
+
15
+ /**
16
+ * Group mutants into groups to check.
17
+ * If missing, groups of singular mutants are assumed.
18
+ * @param mutants the mutants to group
19
+ * @returns the groups of mutant ids
20
+ */
21
+ group?(mutants: Mutant[]): Promise<string[][]>;
22
+ }
@@ -0,0 +1,3 @@
1
+ export * from './checker.js';
2
+ export * from './check-result.js';
3
+ export * from './check-status.js';
@@ -0,0 +1,10 @@
1
+ export enum MutantStatus {
2
+ Init = 'init',
3
+ Ignored = 'ignored',
4
+ NoCoverage = 'noCoverage',
5
+ Killed = 'killed',
6
+ Survived = 'survived',
7
+ TimedOut = 'timedOut',
8
+ RuntimeError = 'runtimeError',
9
+ CompileError = 'compileError',
10
+ }
@@ -0,0 +1,15 @@
1
+ import { MutationRange } from './mutation-range.js';
2
+
3
+ /**
4
+ * Input files by file name.
5
+ */
6
+ export type FileDescriptions = Record<string, FileDescription>;
7
+
8
+ export type MutateDescription = MutationRange[] | boolean;
9
+
10
+ /**
11
+ * The metadata of a input file
12
+ */
13
+ export interface FileDescription {
14
+ mutate: MutateDescription;
15
+ }
@@ -0,0 +1,16 @@
1
+ export type { Position } from './position.js';
2
+ export type { Location } from './location.js';
3
+ export * from './mutant.js';
4
+ export * from '../../src-generated/stryker-core.js';
5
+ export * from './report-types.js';
6
+ export * from './stryker-options-schema.js';
7
+ export * from './partial-stryker-options.js';
8
+ export * from './instrument.js';
9
+ export * from './mutant-coverage.js';
10
+ export * from './mutant-test-plan.js';
11
+ export * from './file-description.js';
12
+ export * from './mutation-range.js';
13
+ /**
14
+ * Re-export all members from "mutation-testing-report-schema" under the `schema` key
15
+ */
16
+ export * as schema from 'mutation-testing-report-schema/api';
@@ -0,0 +1,26 @@
1
+ import { MutantCoverage } from './mutant-coverage.js';
2
+
3
+ /**
4
+ * Identifiers used when instrumenting the code
5
+ */
6
+ export const INSTRUMENTER_CONSTANTS = Object.freeze({
7
+ NAMESPACE: '__stryker__',
8
+ MUTATION_COVERAGE_OBJECT: identity('mutantCoverage'),
9
+ ACTIVE_MUTANT: identity('activeMutant'),
10
+ CURRENT_TEST_ID: identity('currentTestId'),
11
+ HIT_COUNT: identity('hitCount'),
12
+ HIT_LIMIT: identity('hitLimit'),
13
+ ACTIVE_MUTANT_ENV_VARIABLE: '__STRYKER_ACTIVE_MUTANT__',
14
+ } as const);
15
+
16
+ export interface InstrumenterContext {
17
+ activeMutant?: string;
18
+ currentTestId?: string;
19
+ mutantCoverage?: MutantCoverage;
20
+ hitCount?: number;
21
+ hitLimit?: number;
22
+ }
23
+
24
+ function identity<T extends keyof InstrumenterContext>(key: T): T {
25
+ return key;
26
+ }
@@ -0,0 +1,9 @@
1
+ import { Position } from './position.js';
2
+
3
+ /**
4
+ * A location in the source code which can span multiple lines and/or columns.
5
+ */
6
+ export interface Location {
7
+ start: Position;
8
+ end: Position;
9
+ }
@@ -0,0 +1,11 @@
1
+ export interface MutantCoverage {
2
+ static: CoverageData;
3
+ perTest: CoveragePerTestId;
4
+ }
5
+
6
+ export type CoveragePerTestId = Record<string, CoverageData>;
7
+
8
+ /**
9
+ * Keys are mutant ids, the numbers are the amount of times it was hit.
10
+ */
11
+ export type CoverageData = Record<string, number>;
@@ -0,0 +1,56 @@
1
+ import * as schema from 'mutation-testing-report-schema/api';
2
+
3
+ import { MutantRunOptions } from '../test-runner/index.js';
4
+
5
+ import { MutantTestCoverage } from './mutant.js';
6
+
7
+ /**
8
+ * Represents a plan to test a mutant. Can either be an early result (an ignored mutant for example) or a plan to test a mutant in a test runner
9
+ */
10
+ export type MutantTestPlan = MutantEarlyResultPlan | MutantRunPlan;
11
+
12
+ /**
13
+ * The test plans that belong to a mutant.
14
+ */
15
+ export enum PlanKind {
16
+ /**
17
+ * Early result plan, mutant does not have to be checked or run.
18
+ */
19
+ EarlyResult = 'EarlyResult',
20
+ /**
21
+ * Run plan, mutant will have to be checked and run.
22
+ */
23
+ Run = 'Run',
24
+ }
25
+
26
+ /**
27
+ * Represents an mutant early result plan.
28
+ */
29
+ export interface MutantEarlyResultPlan {
30
+ plan: PlanKind.EarlyResult;
31
+ /**
32
+ * The mutant that already has a final status.
33
+ */
34
+ mutant: MutantTestCoverage & { status: schema.MutantStatus };
35
+ }
36
+
37
+ /**
38
+ * Represents a mutant test plan.
39
+ */
40
+ export interface MutantRunPlan {
41
+ plan: PlanKind.Run;
42
+ /**
43
+ * The mutant that has to be tested.
44
+ */
45
+ mutant: MutantTestCoverage;
46
+ /**
47
+ * The run options that will be used to test this mutant
48
+ */
49
+ runOptions: MutantRunOptions;
50
+
51
+ /**
52
+ * Estimated net time to run this mutant when it would survive in ms (which should be the worst case).
53
+ * This is used as input to calculate the runOptions.timeout
54
+ */
55
+ netTime: number;
56
+ }
@@ -0,0 +1,54 @@
1
+ import * as schema from 'mutation-testing-report-schema/api';
2
+ import type { MutantRunExecutedTest } from '../test-runner/index.js';
3
+
4
+ export type { MutantStatus } from 'mutation-testing-report-schema/api';
5
+
6
+ // We're reusing the `MutantResult` interface here to acquire uniformity.
7
+
8
+ /**
9
+ * Represents a mutant in its initial state.
10
+ */
11
+ export interface Mutant extends Pick<
12
+ schema.MutantResult,
13
+ | 'coveredBy'
14
+ | 'id'
15
+ | 'killedBy'
16
+ | 'location'
17
+ | 'mutatorName'
18
+ | 'replacement'
19
+ | 'static'
20
+ | 'statusReason'
21
+ | 'testsCompleted'
22
+ > {
23
+ /**
24
+ * The file name from which this mutant originated
25
+ */
26
+ fileName: string;
27
+ /**
28
+ * Actual mutation that has been applied.
29
+ */
30
+ replacement: string;
31
+ /**
32
+ * The status of a mutant if known. This should be undefined for a mutant that still needs testing.
33
+ */
34
+ status?: schema.MutantStatus;
35
+ }
36
+
37
+ /**
38
+ * Represents a mutant in its matched-with-the-tests state, ready to be tested.
39
+ */
40
+ export type MutantTestCoverage = Mutant &
41
+ Pick<schema.MutantResult, 'coveredBy' | 'static'>;
42
+
43
+ /**
44
+ * Represents a mutant in its final state, ready to be reported.
45
+ */
46
+ export type MutantResult = Mutant &
47
+ schema.MutantResult & {
48
+ /**
49
+ * Optional per-test timing details captured during mutation runs.
50
+ * This field is for runtime/reporter diagnostics and is not part of the
51
+ * mutation-testing-report-schema payload.
52
+ */
53
+ executedTests?: MutantRunExecutedTest[];
54
+ };
@@ -0,0 +1,16 @@
1
+ import { Position } from './position.js';
2
+
3
+ /**
4
+ * Represents a range of mutants that the instrumenter should instrument
5
+ */
6
+ export interface MutationRange {
7
+ /**
8
+ * The start of the range to instrument, by line and column number, inclusive
9
+ */
10
+ start: Position;
11
+
12
+ /**
13
+ * The end of the range to instrument, by line and number, inclusive
14
+ */
15
+ end: Position;
16
+ }
@@ -0,0 +1,14 @@
1
+ import { StrykerOptions } from '../../src-generated/stryker-core.js';
2
+
3
+ /**
4
+ * When configuring stryker, every option is optional
5
+ * Including deep properties like `dashboard.project`.
6
+ * That's why we use a `DeepPartial` mapped type here.
7
+ */
8
+ export type PartialStrykerOptions = DeepPartial<StrykerOptions>;
9
+
10
+ type DeepPartial<T> = {
11
+ [P in keyof T]?: T[P] extends Record<string, any>
12
+ ? DeepPartial<T[P]> | undefined
13
+ : T[P];
14
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A specific spot in the source code based on line and column.
3
+ * Stryker uses zero-based indexes. So the first character in a file is at line 0, column 0.
4
+ */
5
+ export interface Position {
6
+ line: number;
7
+ column: number;
8
+ }
@@ -0,0 +1,6 @@
1
+ import { ReportType } from '../../src-generated/stryker-core.js';
2
+
3
+ export const ALL_REPORT_TYPES = Object.freeze([
4
+ ReportType.Full,
5
+ ReportType.MutationScore,
6
+ ]);
@@ -0,0 +1,11 @@
1
+ import { readFileSync } from 'fs';
2
+ import { URL } from 'url';
3
+
4
+ const strykerCoreSchema: Record<string, unknown> = JSON.parse(
5
+ readFileSync(
6
+ new URL('../../schema/stryker-core.json', import.meta.url),
7
+ 'utf-8',
8
+ ),
9
+ );
10
+
11
+ export { strykerCoreSchema };
@@ -0,0 +1,8 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
2
+ export interface NodePath {
3
+ // Left empty so the declaration can be merged
4
+ }
5
+
6
+ export interface Ignorer {
7
+ shouldIgnore(path: NodePath): string | undefined;
8
+ }
@@ -0,0 +1 @@
1
+ export * from './ignorer.js';
@@ -0,0 +1,2 @@
1
+ export type { Logger } from './logger.js';
2
+ export type { LoggerFactoryMethod } from './logger-factory-method.js';
@@ -0,0 +1,10 @@
1
+ import { Logger } from './logger.js';
2
+
3
+ /**
4
+ * Represents a factory to get loggers by category name.
5
+ * This interface is used to describe the shape of a logger factory method.
6
+ *
7
+ * @param {String} [categoryName] name of category to log to.
8
+ * @returns {Logger} instance of logger for the category
9
+ */
10
+ export type LoggerFactoryMethod = (categoryName?: string) => Logger;
@@ -0,0 +1,15 @@
1
+ export interface Logger {
2
+ isTraceEnabled(): boolean;
3
+ isDebugEnabled(): boolean;
4
+ isInfoEnabled(): boolean;
5
+ isWarnEnabled(): boolean;
6
+ isErrorEnabled(): boolean;
7
+ isFatalEnabled(): boolean;
8
+
9
+ trace(message: string, ...args: any[]): void;
10
+ debug(message: string, ...args: any[]): void;
11
+ info(message: string, ...args: any[]): void;
12
+ warn(message: string, ...args: any[]): void;
13
+ error(message: string, ...args: any[]): void;
14
+ fatal(message: string, ...args: any[]): void;
15
+ }
@@ -0,0 +1,21 @@
1
+ import { FileDescriptions, StrykerOptions } from '../core/index.js';
2
+ import { Logger, LoggerFactoryMethod } from '../logging/index.js';
3
+
4
+ import { commonTokens } from './tokens.js';
5
+
6
+ /**
7
+ * The basic dependency injection context within Stryker
8
+ */
9
+ export interface BaseContext {
10
+ [commonTokens.getLogger]: LoggerFactoryMethod;
11
+ [commonTokens.logger]: Logger;
12
+ }
13
+
14
+ /**
15
+ * The dependency injection context for most of Stryker's plugins.
16
+ * Can inject basic stuff as well as the Stryker options
17
+ */
18
+ export interface PluginContext extends BaseContext {
19
+ [commonTokens.options]: StrykerOptions;
20
+ [commonTokens.fileDescriptions]: FileDescriptions;
21
+ }
@@ -0,0 +1,12 @@
1
+ export * from './contexts.js';
2
+ export * from './plugins.js';
3
+ export * from './plugin-kind.js';
4
+ export * from './tokens.js';
5
+ export * from './scope.js';
6
+ export type {
7
+ Injectable,
8
+ Injector,
9
+ InjectionToken,
10
+ CorrespondingType,
11
+ Disposable,
12
+ } from 'typed-inject';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The plugin kinds supported by Stryker
3
+ */
4
+ export enum PluginKind {
5
+ Checker = 'Checker',
6
+ TestRunner = 'TestRunner',
7
+ Reporter = 'Reporter',
8
+ Ignore = 'Ignore',
9
+ }
@@ -0,0 +1,155 @@
1
+ import type {
2
+ InjectableClass,
3
+ InjectableFunction,
4
+ InjectionToken,
5
+ } from 'typed-inject';
6
+
7
+ import { Reporter } from '../report/index.js';
8
+ import { TestRunner } from '../test-runner/index.js';
9
+ import { Checker } from '../check/index.js';
10
+
11
+ import { Ignorer } from '../ignore/ignorer.js';
12
+
13
+ import { PluginContext } from './contexts.js';
14
+ import { PluginKind } from './plugin-kind.js';
15
+
16
+ /**
17
+ * Represents a StrykerPlugin
18
+ */
19
+ export type Plugin<TPluginKind extends PluginKind> =
20
+ | ClassPlugin<TPluginKind, Array<InjectionToken<PluginContext>>>
21
+ | FactoryPlugin<TPluginKind, Array<InjectionToken<PluginContext>>>
22
+ | ValuePlugin<TPluginKind>;
23
+
24
+ /**
25
+ * Represents a plugin that is created with a factory method
26
+ */
27
+ export interface FactoryPlugin<
28
+ TPluginKind extends PluginKind,
29
+ Tokens extends Array<InjectionToken<PluginContext>>,
30
+ > {
31
+ readonly kind: TPluginKind;
32
+ readonly name: string;
33
+ /**
34
+ * The factory method used to create the plugin
35
+ */
36
+ readonly factory: InjectableFunction<
37
+ PluginContext,
38
+ PluginInterfaces[TPluginKind],
39
+ Tokens
40
+ >;
41
+ }
42
+
43
+ /**
44
+ * Represents a plugin that is provided as a simple value.
45
+ */
46
+ export interface ValuePlugin<TPluginKind extends PluginKind> {
47
+ readonly kind: TPluginKind;
48
+ readonly name: string;
49
+ readonly value: PluginInterfaces[TPluginKind];
50
+ }
51
+
52
+ /**
53
+ * Represents a plugin that is created by instantiating a class.
54
+ */
55
+ export interface ClassPlugin<
56
+ TPluginKind extends PluginKind,
57
+ Tokens extends Array<InjectionToken<PluginContext>>,
58
+ > {
59
+ readonly kind: TPluginKind;
60
+ readonly name: string;
61
+ /**
62
+ * The prototype function (class) used to create the plugin.
63
+ * Not called `class` here, because that is a keyword
64
+ */
65
+ readonly injectableClass: InjectableClass<
66
+ PluginContext,
67
+ PluginInterfaces[TPluginKind],
68
+ Tokens
69
+ >;
70
+ }
71
+
72
+ /**
73
+ * Declare a class plugin. Use this method in order to type check the dependency graph of your plugin
74
+ * @param kind The plugin kind
75
+ * @param name The name of the plugin
76
+ * @param injectableClass The class to be instantiated for the plugin
77
+ */
78
+ export function declareClassPlugin<
79
+ TPluginKind extends PluginKind,
80
+ Tokens extends Array<InjectionToken<PluginContext>>,
81
+ >(
82
+ kind: TPluginKind,
83
+ name: string,
84
+ injectableClass: InjectableClass<
85
+ PluginContext,
86
+ PluginInterfaces[TPluginKind],
87
+ Tokens
88
+ >,
89
+ ): ClassPlugin<TPluginKind, Tokens> {
90
+ return {
91
+ injectableClass,
92
+ kind,
93
+ name,
94
+ };
95
+ }
96
+
97
+ /**
98
+ * Declare a factory plugin. Use this method in order to type check the dependency graph of your plugin,
99
+ * @param kind The plugin kind
100
+ * @param name The name of the plugin
101
+ * @param factory The factory used to instantiate the plugin
102
+ */
103
+ export function declareFactoryPlugin<
104
+ TPluginKind extends PluginKind,
105
+ Tokens extends Array<InjectionToken<PluginContext>>,
106
+ >(
107
+ kind: TPluginKind,
108
+ name: string,
109
+ factory: InjectableFunction<
110
+ PluginContext,
111
+ PluginInterfaces[TPluginKind],
112
+ Tokens
113
+ >,
114
+ ): FactoryPlugin<TPluginKind, Tokens> {
115
+ return {
116
+ factory,
117
+ kind,
118
+ name,
119
+ };
120
+ }
121
+
122
+ /**
123
+ * Declare a value plugin. Use this method for simple plugins where you don't need values to be injected.
124
+ * @param kind The plugin kind
125
+ * @param name The name of the plugin
126
+ * @param value The plugin
127
+ */
128
+ export function declareValuePlugin<TPluginKind extends PluginKind>(
129
+ kind: TPluginKind,
130
+ name: string,
131
+ value: PluginInterfaces[TPluginKind],
132
+ ): ValuePlugin<TPluginKind> {
133
+ return {
134
+ value,
135
+ kind,
136
+ name,
137
+ };
138
+ }
139
+
140
+ /**
141
+ * Lookup type for plugin interfaces by kind.
142
+ */
143
+ export interface PluginInterfaces {
144
+ [PluginKind.Reporter]: Reporter;
145
+ [PluginKind.TestRunner]: TestRunner;
146
+ [PluginKind.Checker]: Checker;
147
+ [PluginKind.Ignore]: Ignorer;
148
+ }
149
+
150
+ /**
151
+ * Lookup type for plugins by kind.
152
+ */
153
+ export type Plugins = {
154
+ [TPluginKind in keyof PluginInterfaces]: Plugin<TPluginKind>;
155
+ };
@@ -0,0 +1,6 @@
1
+ export enum Scope {
2
+ Transient = 'transient',
3
+ Singleton = 'singleton',
4
+ }
5
+
6
+ // Keep in sync with import { Scope } from '@typed-inject';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Define a string literal.
3
+ * @param value Token literal
4
+ */
5
+ function stringLiteral<T extends string>(value: T): T {
6
+ return value;
7
+ }
8
+
9
+ const target: import('typed-inject').TargetToken = '$target';
10
+ const injector: import('typed-inject').InjectorToken = '$injector';
11
+
12
+ /**
13
+ * Common tokens used for dependency injection (see typed-inject readme for more information)
14
+ */
15
+ export const commonTokens = Object.freeze({
16
+ getLogger: stringLiteral('getLogger'),
17
+ injector,
18
+ logger: stringLiteral('logger'),
19
+ options: stringLiteral('options'),
20
+ fileDescriptions: stringLiteral('fileDescriptions'),
21
+ target,
22
+ });
23
+
24
+ /**
25
+ * Helper method to create string literal tuple type.
26
+ * @example
27
+ * ```ts
28
+ * const inject = tokens('foo', 'bar');
29
+ * const inject2: ['foo', 'bar'] = ['foo', 'bar'];
30
+ * ```
31
+ * @param tokens The tokens as args
32
+ */
33
+ export function tokens<TS extends string[]>(...tokensList: TS): TS {
34
+ return tokensList;
35
+ }
@@ -0,0 +1,22 @@
1
+ import {
2
+ CompleteDryRunResult,
3
+ TestRunnerCapabilities,
4
+ } from '../test-runner/index.js';
5
+
6
+ export interface DryRunCompletedEvent {
7
+ result: CompleteDryRunResult;
8
+ timing: RunTiming;
9
+ capabilities: TestRunnerCapabilities;
10
+ }
11
+
12
+ export interface RunTiming {
13
+ /**
14
+ * The time that the test runner was actually executing tests in milliseconds.
15
+ */
16
+ net: number;
17
+ /**
18
+ * the time that was spend not executing tests in milliseconds.
19
+ * So the time it took to start the test runner and to report the result.
20
+ */
21
+ overhead: number;
22
+ }
@@ -0,0 +1,6 @@
1
+ export type { Reporter } from './reporter.js';
2
+ export type { MutationTestingPlanReadyEvent } from './mutation-testing-plan-ready-event.js';
3
+ export type {
4
+ DryRunCompletedEvent,
5
+ RunTiming,
6
+ } from './dry-run-completed-event.js';
@@ -0,0 +1,5 @@
1
+ import { MutantTestPlan } from '../core/index.js';
2
+
3
+ export interface MutationTestingPlanReadyEvent {
4
+ mutantPlans: readonly MutantTestPlan[];
5
+ }