-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reload test environment): implement test environment reload (#3369)
Add the ability for Stryker to restart a test runner in order to reload its test environment. This is used to test static mutants where the test runner is incapable of reloading the test environment by itself. This is a requirement to support es modules (ESM) since it is impossible to reload an ESM using something like `delete require.cache['...']`. Instead, Stryker will restart the entire test runner process for those mutants. The way for the test runner to communicate to Stryker whether it is capable of reloading the environment is by implementing the new `capabilities()` method. ```ts capabilities() { return { reloadEnvironment: true } } ``` If you do this, you can expect the new `reloadEnvironment` boolean in your `MutantRunOptions` to be true when you need to reload the test environment after activating the mutant. BREAKING CHANGE: Test runner plugins must provide `TestRunnerCapabilities` by implementing the `capabilities` method.
- Loading branch information
Showing
37 changed files
with
891 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Represents the capabilities of a test runner. | ||
*/ | ||
export interface TestRunnerCapabilities { | ||
/** | ||
* When true, the test runner is capable of reloading the test environment. Otherwise false. | ||
* Reloading means creating a new nodejs process, or reloading the browser. | ||
* When true, the test runner should reload the test environment when `reloadEnvironment` is present in the run options. | ||
*/ | ||
reloadEnvironment: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './find-mutant-test-coverage'; | ||
export * from './mutant-test-plan'; | ||
export * from './mutant-test-planner'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { MutantStatus, MutantTestCoverage } from '@stryker-mutator/api/core'; | ||
import { MutantRunOptions } from '@stryker-mutator/api/test-runner'; | ||
|
||
/** | ||
* Represents an internal object | ||
*/ | ||
export type MutantTestPlan = MutantEarlyResultPlan | MutantRunPlan; | ||
|
||
export enum PlanKind { | ||
EarlyResult = 'EarlyResult', | ||
Run = 'Run', | ||
} | ||
|
||
export interface MutantEarlyResultPlan { | ||
plan: PlanKind.EarlyResult; | ||
mutant: MutantTestCoverage & { status: MutantStatus }; | ||
} | ||
|
||
export interface MutantRunPlan { | ||
plan: PlanKind.Run; | ||
mutant: MutantTestCoverage; | ||
runOptions: MutantRunOptions; | ||
} |
Oops, something went wrong.