Skip to content

Commit

Permalink
test: fix @slow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianSedzik committed Jul 15, 2023
1 parent 92b3e36 commit 6359e65
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/slow.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import playwright, {expect} from "@playwright/test";
import {suite, test, slow, beforeAll} from "../lib";

const mockSlow = (cb) => {
const mockSlow = (cb: (...args: any[]) => void) => {
const originalSlow = playwright.slow;


// @ts-ignore
playwright.slow = (...args) => {
cb(...args);
}
Expand All @@ -18,6 +19,8 @@ playwright.describe('@slow decorator', () => {
const called: string[] = [];
const cleanup = mockSlow(() => called.push('playwright.slow()'));

playwright.afterAll(() => cleanup());

@slow()
@suite()
class withSlowSuite {
Expand All @@ -31,17 +34,21 @@ playwright.describe('@slow decorator', () => {
called.push('slowTest2');
}
}

playwright('@slow decorator should call playwright.slow() before calling tests', () => {
expect(called).toEqual(['playwright.slow()', 'slowTest', 'slowTest2']);
});

cleanup();
});

playwright.describe('with @test', () => {
const called: string[] = [];
const cleanup = mockSlow(() => called.push('playwright.slow()'));
let cleanup: () => void;

playwright.beforeAll(() => {
cleanup = mockSlow(() => called.push('playwright.slow()'));
});

playwright.afterAll(() => cleanup());

@suite()
class withSlowTestSuite {
Expand All @@ -65,7 +72,5 @@ playwright.describe('@slow decorator', () => {
playwright('@slow decorator should call playwright.slow() before decorated test', () => {
expect(called).toEqual(['test', 'playwright.slow()', 'slowTest', 'test2']);
})

cleanup();
});
});

0 comments on commit 6359e65

Please sign in to comment.