Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
fix(runner): added condition to run all tests if the filter did not d…
Browse files Browse the repository at this point in the history
…etect any matching tests
  • Loading branch information
ryparker committed Jul 22, 2020
1 parent c284371 commit 8b4ce96
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type TestBlock = {
};

export default class AllureTestRunner extends TestRunner {
private readonly _userArgs?: Record<string, string[]> = {};
private readonly _userArgs?: Record<string, string[]>;

constructor(globalConfig: Config.GlobalConfig, context?: JestTestRunnerContext) {
super(globalConfig, context);
Expand All @@ -37,11 +37,17 @@ export default class AllureTestRunner extends TestRunner {
onResult: JestOnTestSuccess,
onFailure: JestOnTestFailure,
options: JestTestRunnerOptions): Promise<void> {
console.debug('User arguments:', this._userArgs);
let testsToRun: JestTest[] = tests;

const testsToRun = this._userArgs && Object.keys(this._userArgs).length > 0 ?
filterByPragma(tests, this._userArgs) :
tests;
if (this._userArgs && Object.keys(this._userArgs).length > 0) {
console.debug('Jest DocBlock runner detected user arguments:', this._userArgs);

const filteredTests = filterByPragma(tests, this._userArgs);

if (filteredTests.length > 0) {
testsToRun = filteredTests;
}
}

return super.runTests(testsToRun, watcher, onStart, onResult, onFailure, options);
}
Expand Down

0 comments on commit 8b4ce96

Please sign in to comment.