Repository navigation
Expand file tree
/
Copy pathvitest-base.config.ts
More file actions
49 lines (46 loc) · 1.88 KB
/
Copy pathvitest-base.config.ts
File metadata and controls
49 lines (46 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Learn more about Vitest configuration options at https://vitest.dev/config/
import { defineConfig } from "vitest/config";
import { availableParallelism } from "node:os";
/**
* Cap the number of parallel test workers.
*
* Each Vitest fork runs a full Angular TestBed + jsdom and holds on to a lot of
* memory. Vitest's default is `cpus - 1` (i.e. 17 forks on an 18-core laptop),
* which exhausts RAM on developer machines. Note that non-interactive runs
* (CI, agents) get the *higher* default, since watch mode halves it.
*
* Override with `VITEST_MAX_WORKERS`, either as a count (`4`) or as a share of
* the available cores (`50%`), when you want a different trade-off.
*/
const workersOverride = process.env.VITEST_MAX_WORKERS;
const maxWorkers = workersOverride?.endsWith("%")
? workersOverride
: Number(workersOverride) ||
Math.max(1, Math.min(4, availableParallelism() - 1));
export default defineConfig({
test: {
globals: true,
/**
* Use jsdom, not happy-dom.
*
* The Angular unit-test builder picks happy-dom whenever it merely *resolves*
* in node_modules — here only as a transitive dependency; `jsdom` is what this
* project actually declares. That default breaks zone.js, which patches DOM
* classes by copying enumerable prototype members: happy-dom declares them as
* ES class methods (non-enumerable), so the patched `MutationObserver` ends up
* with nothing but a constructor. Any spec opening a CDK overlay then fails in
* teardown with "_detachContentMutationObserver.observe is not a function".
*/
environment: "jsdom",
maxWorkers,
sequence: {
hooks: "list",
},
exclude: [
"src/polyfills.test.ts",
"src/environments/environment.spec.ts",
"src/app/utils/expect-entity-data.spec.ts",
"src/app/core/entity/entity-actions/cascading-entity-action.spec.ts",
],
},
});