-
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(jest): report test files and test positions (#2808)
Report the test file names and test positions from the jest-runner plugin back to the main process. They will end up in your JSON report.
- Loading branch information
Showing
22 changed files
with
5,960 additions
and
4,051 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 @@ | |
"clear-text", | ||
"progress", | ||
"html", | ||
"event-recorder" | ||
"event-recorder", | ||
"json" | ||
] | ||
} |
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,22 @@ | ||
import path from 'path'; | ||
|
||
import minimatch from 'minimatch'; | ||
|
||
/** | ||
* A helper class for matching files using the `disableTypeChecks` setting. | ||
*/ | ||
export class FileMatcher { | ||
private readonly pattern: string | false; | ||
|
||
constructor(pattern: string | false) { | ||
if (pattern !== false) { | ||
this.pattern = path.resolve(pattern); | ||
} else { | ||
this.pattern = pattern; | ||
} | ||
} | ||
|
||
public matches(fileName: string): boolean { | ||
return !!this.pattern && minimatch(path.resolve(fileName), this.pattern); | ||
} | ||
} |
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,3 +1,4 @@ | ||
export * from './read-config'; | ||
export * from './options-validator'; | ||
export * from './build-schema-with-plugin-contributions'; | ||
export * from './file-matcher'; |
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,24 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { FileMatcher } from '../../../src/config'; | ||
|
||
describe(FileMatcher.name, () => { | ||
describe(FileMatcher.prototype.matches.name, () => { | ||
it('should match when the glob pattern matches', () => { | ||
const sut = new FileMatcher('src/**/*.ts'); | ||
expect(sut.matches('src/foo.ts')).true; | ||
}); | ||
|
||
it('should not match if the pattern is set to `false`', () => { | ||
const sut = new FileMatcher(false); | ||
expect(sut.matches('src/foo.js')).false; | ||
}); | ||
|
||
it("should not match if the glob pattern doesn't match", () => { | ||
const sut = new FileMatcher('src/**/*.js'); | ||
expect(sut.matches('test/foo.spec.js')).false; | ||
}); | ||
|
||
// more tests would test the internals of minimatch itself. We expect that to work. | ||
}); | ||
}); |
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
Oops, something went wrong.