Skip to content

Commit a582a84

Browse files
committed
test: use separate temp path for init tests
1 parent 7eea613 commit a582a84

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

__tests__/init/init.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import fs from 'fs-extra'
22
import getPort from 'get-port'
3+
import { nanoid } from 'nanoid'
4+
import path from 'path'
35
import { chromium } from 'playwright-chromium'
46
import { fileURLToPath, URL } from 'url'
57
import { createServer, scaffold, ScaffoldThemeType } from 'vitepress'
68

7-
const root = fileURLToPath(new URL('./.temp', import.meta.url))
9+
const tempDir = fileURLToPath(new URL('./.temp', import.meta.url))
10+
const getTempRoot = () => path.join(tempDir, nanoid())
811

912
const browser = await chromium.launch({
1013
headless: !process.env.DEBUG,
@@ -30,9 +33,11 @@ const variations = themes.flatMap((theme) =>
3033
afterAll(async () => {
3134
await page.close()
3235
await browser.close()
36+
await fs.remove(tempDir)
3337
})
3438

3539
test.each(variations)('init %s', async (_, { theme, useTs }) => {
40+
const root = getTempRoot()
3641
await fs.remove(root)
3742
scaffold({ root, theme, useTs, injectNpmScripts: false })
3843

@@ -62,7 +67,6 @@ test.each(variations)('init %s', async (_, { theme, useTs }) => {
6267

6368
// teardown
6469
} finally {
65-
await fs.remove(root)
6670
await server.close()
6771
}
6872
})

0 commit comments

Comments
 (0)