-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.config.ts
37 lines (32 loc) · 986 Bytes
/
vitest.config.ts
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
import { existsSync } from "node:fs";
import { resolve } from "node:path";
import { defineConfig } from "vitest/config";
import type { Reporter, Vitest } from "vitest";
class MainThreadMemoryReporter implements Reporter {
onInit(ctx: Vitest) {
let interval: NodeJS.Timeout;
interval = setInterval(() => {
const heap = Math.floor(process.memoryUsage().heapUsed / 1024 / 1024);
ctx.logger.log(` ⚠️ Memory usage: ${heap} MB heap used`);
if (existsSync(resolve("./coverage/coverage-final.json"))) {
clearInterval(interval);
ctx.logger.log("Stopping memory logger");
}
}, 500);
}
}
export default defineConfig({
test: {
watch: false,
logHeapUsage: true,
reporters: ["verbose", new MainThreadMemoryReporter()],
coverage: {
enabled: true,
provider: "istanbul",
reporter: ["text-summary", "json"],
include: ["src/**"],
// Enabled by default in v1
all: true,
},
},
});