-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(JestTestRunner): run jest with --findRelatedTests #1235
Merged
nicojs
merged 10 commits into
stryker-mutator:master
from
RobertBroersma:jest-findrelatedtests
Nov 29, 2018
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
202f7d8
fix(JestTestRunner): run jest with --findRelatedTests
RobertBroersma eb97511
fix(JestTestRunner): set debug log to trace log
RobertBroersma d8a0f6c
style: remove unnecessary comma and whitespace
RobertBroersma 604ce6e
test: reset log to original
RobertBroersma 87bb365
fix: change ambiguous fileName to mutatedFileName
RobertBroersma 8e64e42
feat(jest-runner): make usage of findRelatedTests configurable
RobertBroersma bff462e
fix(jest-runner): separation of concerns, add some unit tests
RobertBroersma 1d9e7f6
test(sandbox): add mutatedFileName to test cases
RobertBroersma 1de852f
test(jest-runner): add runoptions to testrunner parameters
RobertBroersma 6070dd7
Merge branch 'master' into jest-findrelatedtests
nicojs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion
2
packages/stryker-jest-runner/src/jestTestAdapters/JestTestAdapter.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { RunResult } from 'jest'; | ||
|
||
export default interface JestTestAdapter { | ||
run(config: object, projectRoot: string): Promise<RunResult>; | ||
run(config: object, projectRoot: string, fileNameUnderTest?: string): Promise<RunResult>; | ||
} |
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ describe('JestPromiseTestAdapter', () => { | |
let runCLIStub: sinon.SinonStub; | ||
|
||
const projectRoot = '/path/to/project'; | ||
const fileNameUnderTest = '/path/to/file'; | ||
const jestConfig: any = { rootDir: projectRoot }; | ||
|
||
beforeEach(() => { | ||
|
@@ -37,6 +38,18 @@ describe('JestPromiseTestAdapter', () => { | |
}, [projectRoot])); | ||
}); | ||
|
||
it('should call the runCLI method with the --findRelatedTests flag', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great test! |
||
await jestPromiseTestAdapter.run(jestConfig, projectRoot, fileNameUnderTest); | ||
|
||
assert(runCLIStub.calledWith({ | ||
_: [fileNameUnderTest], | ||
config: JSON.stringify({ rootDir: projectRoot, reporters: [] }), | ||
findRelatedTests: true, | ||
runInBand: true, | ||
silent: true | ||
}, [projectRoot])); | ||
}); | ||
|
||
it('should call the runCLI method and return the test result', async () => { | ||
const result = await jestPromiseTestAdapter.run(jestConfig, projectRoot); | ||
|
||
|
@@ -50,6 +63,21 @@ describe('JestPromiseTestAdapter', () => { | |
}); | ||
}); | ||
|
||
it('should call the runCLI method and return the test result when run with --findRelatedTests flag', async () => { | ||
const result = await jestPromiseTestAdapter.run(jestConfig, projectRoot, fileNameUnderTest); | ||
|
||
expect(result).to.deep.equal({ | ||
config: { | ||
nicojs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_: [fileNameUnderTest], | ||
config: JSON.stringify({ rootDir: projectRoot, reporters: [] }), | ||
findRelatedTests: true, | ||
runInBand: true, | ||
silent: true | ||
}, | ||
result: 'testResult' | ||
}); | ||
}); | ||
|
||
it('should trace log a message when jest is invoked', async () => { | ||
await jestPromiseTestAdapter.run(jestConfig, projectRoot); | ||
|
||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can log on debug what we are doing with this setting?