-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sandbox): Change cwd in
Sandbox
es (#187)
* feat(sandbox): Change cwd in `Sandbox`es Change the current working directory for all isolated sandboxes. This is needed to remove unwanted side effects during test runs. For example RequireJS wasn't able to find files in combination with karma. * Add new interface `IsolatedRunnerOptions`, which extends `RunnerOptions` with the addition of `SandboxWorkingFolder` * Change working directory as soon as the IsoltatedTestRunnerAdapterWorker has loaded the plugins as they can be relative to the parent working directory. * fix(typescript): Set back typescript version
- Loading branch information
Showing
10 changed files
with
82 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { RunnerOptions } from 'stryker-api/test_runner'; | ||
|
||
interface IsolatedRunnerOptions extends RunnerOptions { | ||
sandboxWorkingFolder: string; | ||
} | ||
|
||
export default IsolatedRunnerOptions; |
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import { TestRunnerFactory, TestRunner, RunnerOptions } from 'stryker-api/test_runner'; | ||
import { TestRunnerFactory, TestRunner } from 'stryker-api/test_runner'; | ||
import IsolatedTestRunnerAdapter from './IsolatedTestRunnerAdapter'; | ||
import IsolatedRunnerOptions from './IsolatedRunnerOptions'; | ||
|
||
|
||
|
||
export default { | ||
create(settings: RunnerOptions): IsolatedTestRunnerAdapter { | ||
create(settings: IsolatedRunnerOptions): IsolatedTestRunnerAdapter { | ||
return new IsolatedTestRunnerAdapter(settings.strykerOptions.testRunner, settings); | ||
} | ||
}; |
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
16 changes: 16 additions & 0 deletions
16
test/integration/isolated-runner/VerifyWorkingFolderTestRunner.ts
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,16 @@ | ||
import { EventEmitter } from 'events'; | ||
import { RunResult, RunStatus, RunOptions, TestRunner, TestRunnerFactory } from 'stryker-api/test_runner'; | ||
class VerifyWorkingFolderTestRunner extends EventEmitter implements TestRunner { | ||
|
||
runResult: RunResult = { status: RunStatus.Complete, tests: [] }; | ||
|
||
run(options: RunOptions) { | ||
if (process.cwd() === __dirname) { | ||
return Promise.resolve(this.runResult); | ||
} else { | ||
return Promise.reject(new Error(`Expected ${process.cwd()} to be ${__dirname}`)); | ||
} | ||
} | ||
} | ||
|
||
TestRunnerFactory.instance().register('verify-working-folder', VerifyWorkingFolderTestRunner); |
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