chore: split playwright.fixtures into files (5) (#3986)
This commit is contained in:
parent
0ee9050f1b
commit
423485e0a4
|
|
@ -108,18 +108,13 @@ defineWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test
|
||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
defineTestFixture('testOutputDir', async ({ testInfo }, runTest) => {
|
defineTestFixture('testOutputDir', async ({ testInfo, browserName }, runTest) => {
|
||||||
const relativePath = path.relative(config.testDir, testInfo.file).replace(/\.spec\.[jt]s/, '');
|
const relativePath = path.relative(config.testDir, testInfo.file)
|
||||||
|
.replace(/\.spec\.[jt]s/, '')
|
||||||
|
.replace(/\.test\.[jt]s/, '');
|
||||||
const sanitizedTitle = testInfo.title.replace(/[^\w\d]+/g, '_');
|
const sanitizedTitle = testInfo.title.replace(/[^\w\d]+/g, '_');
|
||||||
const testOutputDir = path.join(config.outputDir, relativePath, sanitizedTitle);
|
const testOutputDir = path.join(config.outputDir, relativePath, sanitizedTitle, browserName);
|
||||||
await fs.promises.mkdir(testOutputDir, { recursive: true });
|
|
||||||
await runTest(testOutputDir);
|
await runTest(testOutputDir);
|
||||||
const files = await fs.promises.readdir(testOutputDir);
|
|
||||||
if (!files.length) {
|
|
||||||
// Do not leave an empty useless directory.
|
|
||||||
// This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
|
|
||||||
await removeFolderAsync(testOutputDir).catch(e => {});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
defineTestFixture('context', async ({ browser, testOutputDir }, runTest) => {
|
defineTestFixture('context', async ({ browser, testOutputDir }, runTest) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue