Skip to content

Commit

Permalink
feat: skip suites in bail mode
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jan 6, 2025
1 parent 17d3924 commit bb179b3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Emitter } from './emitter.js'
import { Tracker } from './tracker.js'
import { ReporterContract, RunnerSummary } from './types.js'
import { SummaryBuilder } from './summary_builder.js'
import { Group } from './group/main.js'

/**
* The Runner class exposes the API to register test suites and execute
Expand Down Expand Up @@ -179,14 +180,23 @@ export class Runner<Context extends Record<any, any>> extends Macroable {
*/
async exec() {
for (let suite of this.suites) {
/**
* Skip tests in bail mode when there is an error
*/
if (this.#bail && this.#failed) {
suite.stack.forEach((groupOrTest) => {
if (groupOrTest instanceof Group) {
groupOrTest.tap((t) => t.skip(true, 'Skipped due to bail mode'))
} else {
groupOrTest.skip(true, 'Skipped due to bail mode')
}
})
}

await suite.exec()
if (!this.#failed && suite.failed) {
this.#failed = true
}

if (this.#bail && this.#failed) {
break
}
}
}

Expand Down

0 comments on commit bb179b3

Please sign in to comment.