Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export default defineConfig({
retries: process.env.CI ? 1 : 0,
reporter: process.env.CI ? [['list'], ['html', { open: 'never' }]] : 'list',
use: { trace: 'retain-on-failure' },
globalSetup: './tests/run-tmp.ts',
})
20 changes: 20 additions & 0 deletions tests/run-tmp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { mkdtempSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'

/**
* Global setup for both test runners: on Linux, one temp folder per run, removed when the run
* ends. Workers, and the apps they launch, inherit `TMPDIR`, so every folder a test makes with
* `tmpdir()` (an app's user data, a download folder, a saved page) and the apps' own temp files
* go under it. Before, each e2e test left its user data in /tmp: about 3 MB a test, over 1 GB a
* full run. A run that is killed leaves its one folder behind.
*
* Linux only: on Windows `tmpdir()` reads TEMP and TMP, not `TMPDIR`, and nothing runs the suite
* on macOS or Windows now (D42), so it's untested there.
*/
export default function runTmp(): () => void {
if (process.platform !== 'linux') return () => {}
const dir = mkdtempSync(join(tmpdir(), 'orbit-run-'))
process.env.TMPDIR = dir
return () => rmSync(dir, { recursive: true, force: true })
}
1 change: 1 addition & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default defineConfig({
test: {
include: ['tests/unit/**/*.test.ts'],
environment: 'node',
globalSetup: ['tests/run-tmp.ts'],
// Persistence tests fsync real files; CI disks (macOS runners) can take seconds.
testTimeout: 15_000,
},
Expand Down