mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
test(cli): give each test file its own home so renders never wait on another file's lock (#7526)
* test(cli): give each test file its own home so renders never wait on another file's lock * test(cli): pin the cli test config after adding the per-file home setup
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// Each test file gets a home of its own: per-user state such as the render lock is never
|
||||
// shared by test files running at the same time, so one file's render cannot make another's wait.
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterAll } from "vitest";
|
||||
|
||||
const home = mkdtempSync(join(tmpdir(), "hf-test-file-home-"));
|
||||
process.env.HOME = process.env.USERPROFILE = home;
|
||||
afterAll(() => rmSync(home, { recursive: true, force: true }));
|
||||
@@ -0,0 +1,8 @@
|
||||
import { homedir } from "node:os";
|
||||
import { hyperframesCacheDir } from "@hyperframes/core/cache-dir";
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
it("gives each test file its own home, so files never share the per-user render lock", () => {
|
||||
expect(homedir()).toMatch(/hf-test-file-home-/);
|
||||
expect(hyperframesCacheDir("locks", "render.lock").startsWith(homedir())).toBe(true);
|
||||
});
|
||||
@@ -61,6 +61,7 @@ export default defineConfig({
|
||||
// hang. Prefer this one config knob over per-test/per-hook timeout bandaids.
|
||||
testTimeout: 20_000,
|
||||
hookTimeout: 30_000,
|
||||
setupFiles: ["./scripts/test-file-home.mjs"],
|
||||
// Tests that drive a real Chrome (the four *.process.test.ts named here start one) run alone, after
|
||||
// everything else: a Chrome beside hundreds of parallel files was starved past its 30 s launch limit.
|
||||
projects: [
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
"command": "vitest run --shard=${{ matrix.shard }}/2",
|
||||
"tests": ["packages/cli/src/**/*.test.ts"],
|
||||
"sources": {
|
||||
"packages/cli/vitest.config.ts": "9bd2a87aaf33d3cd7fc397c30ae914468a3731a6fae1ffe7cdd1bf3450cbe900",
|
||||
"packages/cli/vitest.config.ts": "135ef1c442b32ec5316b23e24d2f8cf0111d889fcb141c95dbd933cf2eaaf8f4",
|
||||
".github/workflows/ci.yml#job#test-cli": "66a1249d0d3f0e6f72adb4c22bf7f76b7a8dabcee3204b6bf8cbcc636a9d7cb4",
|
||||
"packages/cli/package.json#script#test": "ad6cd6b8acf39571390d7bc1772410249266fa406be150a22f0065827e400496"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user