Skip to content

Commit

Permalink
feat: allow the runner to run beforeAll/afterAll hooks (#360)
Browse files Browse the repository at this point in the history
It's useful if you want to combine these hooks with custom
runStep invocations.
  • Loading branch information
OrKoN committed Nov 2, 2022
1 parent 2dba511 commit 3c4ece0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export class Runner {
this.#flow = flow;
}

async runBeforeAllSteps(flow?: UserFlow): Promise<void> {
await this.#extension.beforeAllSteps?.(flow);
}

async runAfterAllSteps(flow?: UserFlow): Promise<void> {
await this.#extension.afterAllSteps?.(flow);
}

/**
* Runs the provided `step` with `beforeEachStep` and `afterEachStep` hooks.
* Parameters from the `flow` apply if the `flow` is set.
Expand Down
6 changes: 6 additions & 0 deletions test/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,12 @@ describe('Runner', () => {
extension.getLog(),
'beforeAll,beforeStep0,runStep0,afterStep0,afterAll'
);
await runner.runBeforeAllSteps();
await runner.runAfterAllSteps();
assert.strictEqual(
extension.getLog(),
'beforeAll,beforeStep0,runStep0,afterStep0,afterAll,beforeAll,afterAll'
);
});

it('should record interactions with OOPIFs', async () => {
Expand Down

0 comments on commit 3c4ece0

Please sign in to comment.