Skip to content

Commit c45b579

Browse files
authored
test: support slow marker (#3018)
1 parent 7d2078e commit c45b579

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

test/defaultbrowsercontext.jest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ describe('launchPersistentContext()', function() {
290290
await removeUserDataDir(userDataDir);
291291
await removeUserDataDir(userDataDir2);
292292
});
293-
it.slow().fail(CHROMIUM && (WIN || MAC))('should restore cookies from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => {
293+
it.fail(CHROMIUM && (WIN || MAC)).slow()('should restore cookies from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => {
294294
const userDataDir = await makeUserDataDir();
295295
const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions);
296296
const page = await browserContext.newPage();

test/headful.jest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Headful', function() {
2727
await browserContext.close();
2828
await removeUserDataDir(userDataDir);
2929
});
30-
it.slow().fail(WIN && CHROMIUM)('headless should be able to read cookies written by headful', async({browserType, defaultBrowserOptions, server}) => {
30+
it.fail(WIN && CHROMIUM).slow()('headless should be able to read cookies written by headful', async({browserType, defaultBrowserOptions, server}) => {
3131
// see https://github.com/microsoft/playwright/issues/717
3232
const userDataDir = await makeUserDataDir();
3333
// Write a cookie in headful chrome

test/jest/playwrightEnvironment.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,21 @@ class PlaywrightEnvironment extends NodeEnvironment {
6464
return super.runScript(script);
6565
}
6666

67+
patchToEnableFixtures(object, name) {
68+
const original = object[name];
69+
object[name] = fn => {
70+
return original(async () => {
71+
return await this.fixturePool.resolveParametersAndRun(fn);
72+
});
73+
}
74+
}
75+
6776
async handleTestEvent(event, state) {
6877
if (event.name === 'setup') {
69-
const beforeEach = this.global.beforeEach;
70-
this.global.beforeEach = fn => {
71-
return beforeEach(async () => {
72-
return await this.fixturePool.resolveParametersAndRun(fn);
73-
});
74-
}
78+
79+
this.patchToEnableFixtures(this.global, 'beforeEach');
80+
this.patchToEnableFixtures(this.global, 'afterEach');
81+
7582
const describeSkip = this.global.describe.skip;
7683
this.global.describe.skip = (...args) => {
7784
if (args.length = 1)
@@ -88,7 +95,11 @@ class PlaywrightEnvironment extends NodeEnvironment {
8895
return itSkip(...args);
8996
};
9097
this.global.it.fail = this.global.it.skip;
91-
this.global.it.slow = () => this.global.it;
98+
this.global.it.slow = () => {
99+
return (name, fn) => {
100+
return this.global.it(name, fn, 90000);
101+
}
102+
}
92103

93104
const testOptions = this.global.testOptions;
94105
function toBeGolden(received, goldenName) {

test/launcher.jest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('Playwright', function() {
7676
const error = await browserType.launch(options).catch(e => e);
7777
expect(error.message).toContain('<launching>');
7878
});
79-
it.slow().skip(CHANNEL)('should accept objects as options', async({browserType, defaultBrowserOptions}) => {
79+
it.skip(CHANNEL).slow()('should accept objects as options', async({browserType, defaultBrowserOptions}) => {
8080
const browser = await browserType.launch({ ...defaultBrowserOptions, process });
8181
await browser.close();
8282
});

0 commit comments

Comments
 (0)