test: support slow marker (#3018)

This commit is contained in:
Pavel Feldman 2020-07-17 17:17:06 -07:00 committed by GitHub
parent 7d2078ef6f
commit c45b5797fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 10 deletions

View File

@ -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();

View File

@ -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

View File

@ -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)
@ -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) {

View File

@ -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();
});