Skip to content

Commit

Permalink
feat: expose runner info in hooks (#960)
Browse files Browse the repository at this point in the history
* feat: expose testinfo in hooks

* fix test

* improve types

* some more cleanups

* expose runner info in hooks

* add test for info

* add pending status

* expose info in journey args
  • Loading branch information
vigneshshanmugam authored Oct 1, 2024
1 parent 03c74b8 commit c730775
Show file tree
Hide file tree
Showing 24 changed files with 738 additions and 768 deletions.
4 changes: 2 additions & 2 deletions __tests__/core/gatherer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe('Gatherer', () => {
wsEndpoint,
playwrightOptions: { navigationTimeout: 1, actionTimeout: 2 },
});
server.route('/hang.html', () => {});
server.route('/hang.html', () => { });
let error: any = null;
await driver.page
.goto(server.PREFIX + '/hang.html')
Expand All @@ -287,7 +287,7 @@ describe('Gatherer', () => {
wsEndpoint,
playwrightOptions: { navigationTimeout: 3 },
});
server.route('/hang.html', () => {});
server.route('/hang.html', () => { });
let error: any = null;
await driver.page
.goto(server.PREFIX + '/hang.html', { timeout: 1 })
Expand Down
22 changes: 11 additions & 11 deletions __tests__/core/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
import {
journey,
step,
runner,
before,
after,
beforeAll,
afterAll,
} from '../../src/core/index';
import { runner } from '../../src/core/globals';

beforeEach(async () => await runner.reset());
beforeEach(async () => await runner._reset());

const noop = () => {};
const noop = () => { };
const name = 'journey';

it('add global hooks to runner', () => {
Expand All @@ -54,7 +54,7 @@ it('add journeys to runner', () => {

expect(j.name).toBe(name);
expect(j.id).toBe(name);
expect(runner.currentJourney).toEqual(j);
expect(runner.journey).toEqual(j);
expect(runner.journeys.length).toBe(1);
});

Expand All @@ -63,22 +63,22 @@ it('add steps to journeys', () => {
const s1 = step('step1', noop);
const s2 = step('step2', noop);

expect(runner.currentJourney).toEqual(j);
expect(runner.journey).toEqual(j);
expect(runner.journeys.length).toBe(1);
expect(runner.currentJourney?.steps.length).toBe(2);
expect(runner.currentJourney?.steps).toEqual([s1, s2]);
expect(runner.journey?.steps.length).toBe(2);
expect(runner.journey?.steps).toEqual([s1, s2]);
});

it('add hooks to journeys', () => {
const j = journey(name, noop);
before(noop);
after(noop);

expect(runner.currentJourney).toEqual(j);
expect(runner.journey).toEqual(j);
expect(runner.journeys.length).toBe(1);
expect(runner.currentJourney?.steps.length).toBe(0);
expect(runner.currentJourney?.hooks.before).toEqual([noop]);
expect(runner.currentJourney?.hooks.after).toEqual([noop]);
expect(runner.journey?.steps.length).toBe(0);
expect(runner.journey?._getHook("before")).toEqual([noop]);
expect(runner.journey?._getHook("after")).toEqual([noop]);
});

it('add hooks - error on before/after outside journey context', () => {
Expand Down
Loading

0 comments on commit c730775

Please sign in to comment.