Skip to content

Commit 423485e

Browse files
authored
chore: split playwright.fixtures into files (5) (#3986)
1 parent 0ee9050 commit 423485e

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

test/playwright.fixtures.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,13 @@ defineWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test
108108
await browser.close();
109109
});
110110

111-
defineTestFixture('testOutputDir', async ({ testInfo }, runTest) => {
112-
const relativePath = path.relative(config.testDir, testInfo.file).replace(/\.spec\.[jt]s/, '');
111+
defineTestFixture('testOutputDir', async ({ testInfo, browserName }, runTest) => {
112+
const relativePath = path.relative(config.testDir, testInfo.file)
113+
.replace(/\.spec\.[jt]s/, '')
114+
.replace(/\.test\.[jt]s/, '');
113115
const sanitizedTitle = testInfo.title.replace(/[^\w\d]+/g, '_');
114-
const testOutputDir = path.join(config.outputDir, relativePath, sanitizedTitle);
115-
await fs.promises.mkdir(testOutputDir, { recursive: true });
116+
const testOutputDir = path.join(config.outputDir, relativePath, sanitizedTitle, browserName);
116117
await runTest(testOutputDir);
117-
const files = await fs.promises.readdir(testOutputDir);
118-
if (!files.length) {
119-
// Do not leave an empty useless directory.
120-
// This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
121-
await removeFolderAsync(testOutputDir).catch(e => {});
122-
}
123118
});
124119

125120
defineTestFixture('context', async ({ browser, testOutputDir }, runTest) => {

0 commit comments

Comments
 (0)