mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
It should be opt-in and configurable. The folder we collect information into should be consistent with the rest of the artifacts we collect. Lets revisit it later.
This commit is contained in:
parent
d8a17fb0ab
commit
baa0956915
@ -26,8 +26,6 @@ const { PlaywrightDispatcher } = require('../../lib/rpc/server/playwrightDispatc
|
||||
const { setUseApiName } = require('../../lib/progress');
|
||||
|
||||
const browserName = process.env.BROWSER || 'chromium';
|
||||
const activeBrowsers = new Set();
|
||||
global.__activeBrowsers__ = activeBrowsers;
|
||||
|
||||
module.exports = function registerFixtures(global) {
|
||||
global.registerWorkerFixture('parallelIndex', async ({}, test) => {
|
||||
@ -139,7 +137,6 @@ module.exports = function registerFixtures(global) {
|
||||
|
||||
global.registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => {
|
||||
const browser = await browserType.launch(defaultBrowserOptions);
|
||||
activeBrowsers.add(browser);
|
||||
try {
|
||||
await test(browser);
|
||||
if (browser.contexts().length !== 0) {
|
||||
@ -147,7 +144,6 @@ module.exports = function registerFixtures(global) {
|
||||
await Promise.all(browser.contexts().map(context => context.close()));
|
||||
}
|
||||
} finally {
|
||||
activeBrowsers.delete(browser);
|
||||
await browser.close();
|
||||
}
|
||||
});
|
||||
|
||||
@ -132,34 +132,15 @@ class PlaywrightEnvironment extends NodeEnvironment {
|
||||
if (event.name === 'test_start') {
|
||||
const fn = event.test.fn;
|
||||
event.test.fn = async () => {
|
||||
return await this.fixturePool.resolveParametersAndRun(fn);
|
||||
try {
|
||||
return await this.fixturePool.resolveParametersAndRun(fn);
|
||||
} finally {
|
||||
await this.fixturePool.teardownScope('test');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (event.name === 'test_fn_success')
|
||||
await this.fixturePool.teardownScope('test');
|
||||
|
||||
if (event.name === 'test_fn_failure') {
|
||||
let index = 0;
|
||||
for (const browser of global.__activeBrowsers__ || []) {
|
||||
for (const context of /** @type {import('../../').Browser} */ (browser).contexts()) {
|
||||
const pages = context.pages();
|
||||
const names = [];
|
||||
let current = event.test;
|
||||
while (current && current.name !== 'ROOT_DESCRIBE_BLOCK') {
|
||||
names.push(current.name)
|
||||
current = current.parent;
|
||||
}
|
||||
const fullName = names.reverse().join(' ')
|
||||
await Promise.all(pages.map(async (page) => {
|
||||
const filename = fullName.replace(/\s/g, '-') + '-' + index++ + '.png';
|
||||
await page.screenshot({
|
||||
path: path.join(this.global.testOptions.OUTPUT_DIR, filename)
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
await this.fixturePool.teardownScope('test');
|
||||
await this.fixturePool.teardownScope('worker');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user