Skip to content

Commit

Permalink
chore: split playwright.fixtures into files (5) (#3986)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Sep 26, 2020
1 parent 0ee9050 commit 423485e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions test/playwright.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,13 @@ defineWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test
await browser.close();
});

defineTestFixture('testOutputDir', async ({ testInfo }, runTest) => {
const relativePath = path.relative(config.testDir, testInfo.file).replace(/\.spec\.[jt]s/, '');
defineTestFixture('testOutputDir', async ({ testInfo, browserName }, runTest) => {
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 testOutputDir = path.join(config.outputDir, relativePath, sanitizedTitle);
await fs.promises.mkdir(testOutputDir, { recursive: true });
const testOutputDir = path.join(config.outputDir, relativePath, sanitizedTitle, browserName);
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) => {
Expand Down

0 comments on commit 423485e

Please sign in to comment.