|
1 | | -import { resolve } from "pathe"; |
| 1 | +import { tmpdir } from "node:os"; |
| 2 | +import { promises as fsp } from "node:fs"; |
| 3 | +import { join, resolve } from "pathe"; |
2 | 4 | import { listen, Listener } from "listhen"; |
| 5 | +import fse from "fs-extra"; |
3 | 6 | import destr from "destr"; |
4 | 7 | import { fetch, FetchOptions } from "ofetch"; |
5 | 8 | import { expect, it, afterAll, beforeAll, describe } from "vitest"; |
@@ -35,16 +38,19 @@ export const describeIf = (condition, title, factory) => |
35 | 38 |
|
36 | 39 | export async function setupTest(preset: string) { |
37 | 40 | const fixtureDir = fileURLToPath(new URL("fixture", import.meta.url).href); |
38 | | - |
39 | | - const presetTempDir = fileURLToPath( |
40 | | - new URL(`presets/.tmp/${preset}`, import.meta.url).href |
| 41 | + const presetTempDir = resolve( |
| 42 | + process.env.NITRO_TEST_TMP_DIR || join(tmpdir(), "nitro-tests"), |
| 43 | + preset |
41 | 44 | ); |
42 | 45 |
|
| 46 | + await fsp.rm(presetTempDir, { recursive: true }).catch(() => {}); |
| 47 | + await fsp.mkdir(presetTempDir, { recursive: true }); |
| 48 | + |
43 | 49 | const ctx: Context = { |
44 | 50 | preset, |
45 | 51 | isDev: preset === "nitro-dev", |
46 | 52 | rootDir: fixtureDir, |
47 | | - outDir: resolve(fixtureDir, presetTempDir, ".output"), |
| 53 | + outDir: resolve(fixtureDir, presetTempDir, "output"), |
48 | 54 | fetch: (url, opts) => |
49 | 55 | fetch(joinURL(ctx.server!.url, url.slice(1)), { |
50 | 56 | redirect: "manual", |
|
0 commit comments