Skip to content

Commit

Permalink
test: support slow marker (#3018)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Jul 18, 2020
1 parent 7d2078e commit c45b579
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion test/defaultbrowsercontext.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('launchPersistentContext()', function() {
await removeUserDataDir(userDataDir);
await removeUserDataDir(userDataDir2);
});
it.slow().fail(CHROMIUM && (WIN || MAC))('should restore cookies from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => {
it.fail(CHROMIUM && (WIN || MAC)).slow()('should restore cookies from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => {
const userDataDir = await makeUserDataDir();
const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions);
const page = await browserContext.newPage();
Expand Down
2 changes: 1 addition & 1 deletion test/headful.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Headful', function() {
await browserContext.close();
await removeUserDataDir(userDataDir);
});
it.slow().fail(WIN && CHROMIUM)('headless should be able to read cookies written by headful', async({browserType, defaultBrowserOptions, server}) => {
it.fail(WIN && CHROMIUM).slow()('headless should be able to read cookies written by headful', async({browserType, defaultBrowserOptions, server}) => {
// see https://github.com/microsoft/playwright/issues/717
const userDataDir = await makeUserDataDir();
// Write a cookie in headful chrome
Expand Down
25 changes: 18 additions & 7 deletions test/jest/playwrightEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,21 @@ class PlaywrightEnvironment extends NodeEnvironment {
return super.runScript(script);
}

patchToEnableFixtures(object, name) {
const original = object[name];
object[name] = fn => {
return original(async () => {
return await this.fixturePool.resolveParametersAndRun(fn);
});
}
}

async handleTestEvent(event, state) {
if (event.name === 'setup') {
const beforeEach = this.global.beforeEach;
this.global.beforeEach = fn => {
return beforeEach(async () => {
return await this.fixturePool.resolveParametersAndRun(fn);
});
}

this.patchToEnableFixtures(this.global, 'beforeEach');
this.patchToEnableFixtures(this.global, 'afterEach');

const describeSkip = this.global.describe.skip;
this.global.describe.skip = (...args) => {
if (args.length = 1)
Expand All @@ -88,7 +95,11 @@ class PlaywrightEnvironment extends NodeEnvironment {
return itSkip(...args);
};
this.global.it.fail = this.global.it.skip;
this.global.it.slow = () => this.global.it;
this.global.it.slow = () => {
return (name, fn) => {
return this.global.it(name, fn, 90000);
}
}

const testOptions = this.global.testOptions;
function toBeGolden(received, goldenName) {
Expand Down
2 changes: 1 addition & 1 deletion test/launcher.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('Playwright', function() {
const error = await browserType.launch(options).catch(e => e);
expect(error.message).toContain('<launching>');
});
it.slow().skip(CHANNEL)('should accept objects as options', async({browserType, defaultBrowserOptions}) => {
it.skip(CHANNEL).slow()('should accept objects as options', async({browserType, defaultBrowserOptions}) => {
const browser = await browserType.launch({ ...defaultBrowserOptions, process });
await browser.close();
});
Expand Down

0 comments on commit c45b579

Please sign in to comment.