Skip to content

Commit

Permalink
Merge pull request #4184 from DavidRieman/drieman/rushTestPathIgnoreP…
Browse files Browse the repository at this point in the history
…atterns

[heft-jest-plugin] Add --test-path-ignore-patterns CLI option.
  • Loading branch information
D4N14L authored Jun 9, 2023
2 parents 0508cd7 + 0698110 commit 3747596
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-jest-plugin",
"comment": "Added --test-path-ignore-patterns support for subtractive test selection to complement existing additive support.",
"type": "patch"
}
],
"packageName": "@rushstack/heft-jest-plugin"
}
6 changes: 6 additions & 0 deletions heft-plugins/heft-jest-plugin/heft-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
"argumentName": "REGEXP",
"description": "Run only tests with a name that matches a regular expression. The REGEXP is matched against the full name, which is a combination of the test name and all its surrounding describe blocks. This corresponds to the \"--testNamePattern\" parameter in Jest's documentation."
},
{
"longName": "--test-path-ignore-patterns",
"parameterKind": "string",
"argumentName": "REGEXP",
"description": "Avoid running tests with a source file path that matches one ore more regular expressions. On Windows you will need to use \"/\" instead of \"\\\". This corresponds to the \"--testPathIgnorePatterns\" parameter in Jest's documentation."
},
{
"longName": "--test-path-pattern",
"parameterKind": "string",
Expand Down
6 changes: 6 additions & 0 deletions heft-plugins/heft-jest-plugin/src/JestPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface IJestPluginOptions {
passWithNoTests?: boolean;
silent?: boolean;
testNamePattern?: string;
testPathIgnorePatterns?: string;
testPathPattern?: string;
testTimeout?: number;
updateSnapshots?: boolean;
Expand Down Expand Up @@ -183,6 +184,9 @@ export default class JestPlugin implements IHeftTaskPlugin<IJestPluginOptions> {
const maxWorkersParameter: CommandLineStringParameter = parameters.getStringParameter('--max-workers');
const testNamePatternParameter: CommandLineStringParameter =
parameters.getStringParameter('--test-name-pattern');
const testPathIgnorePatternsParameter: CommandLineStringParameter = parameters.getStringParameter(
'--test-path-ignore-patterns'
);
const testPathPatternParameter: CommandLineStringParameter =
parameters.getStringParameter('--test-path-pattern');

Expand All @@ -208,6 +212,7 @@ export default class JestPlugin implements IHeftTaskPlugin<IJestPluginOptions> {
passWithNoTests: true,
silent: silentParameter.value || pluginOptions?.silent,
testNamePattern: testNamePatternParameter.value || pluginOptions?.testNamePattern,
testPathIgnorePatterns: testPathIgnorePatternsParameter.value || pluginOptions?.testPathIgnorePatterns,
testPathPattern: testPathPatternParameter.value || pluginOptions?.testPathPattern,
testTimeout: testTimeoutParameter.value ?? pluginOptions?.testTimeout,
updateSnapshots: updateSnapshotsParameter.value || pluginOptions?.updateSnapshots
Expand Down Expand Up @@ -564,6 +569,7 @@ export default class JestPlugin implements IHeftTaskPlugin<IJestPluginOptions> {

silent: options.silent || false,
testNamePattern: options.testNamePattern,
testPathIgnorePatterns: options.testPathIgnorePatterns ? [options.testPathIgnorePatterns] : undefined,
testPathPattern: options.testPathPattern ? [options.testPathPattern] : undefined,
testTimeout: options.testTimeout,
maxWorkers: options.maxWorkers,
Expand Down

0 comments on commit 3747596

Please sign in to comment.