-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.ts
More file actions
54 lines (52 loc) · 1.63 KB
/
Copy pathvitest.config.ts
File metadata and controls
54 lines (52 loc) · 1.63 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
50
51
52
53
54
import { playwright } from "@vitest/browser-playwright";
import solid from "vite-plugin-solid";
import { defineConfig } from "vitest/config";
import type { Plugin } from "vite";
// vite-plugin-solid automatically injects @testing-library/jest-dom into
// setupFiles when it detects the module in pnpm's store. Because the image
// package does not depend on jest-dom, the import fails at runtime.
// Strip the injected entry so vitest never tries to load it.
const stripJestDomSetup: Plugin = {
name: "strip-jest-dom-setup",
config(config) {
const files = config.test?.setupFiles;
if (Array.isArray(files)) {
config.test!.setupFiles = files.filter(
f => typeof f !== "string" || !f.includes("jest-dom"),
);
}
},
};
export default defineConfig({
test: {
projects: [
{
// Server rendering and the Vite plugin, which both run in Node.
plugins: [solid({ ssr: true }), stripJestDomSetup],
test: {
name: "node",
globals: true,
environment: "node",
include: ["src/__tests__/*.test.{ts,tsx}"],
},
},
{
// Client rendering, which needs a real IntersectionObserver and a
// browser that loads images.
plugins: [solid(), stripJestDomSetup],
test: {
name: "browser",
globals: true,
include: ["src/__tests__/browser/*.test.{ts,tsx}"],
browser: {
enabled: true,
provider: playwright(),
headless: true,
screenshotFailures: false,
instances: [{ browser: "chromium" }],
},
},
},
],
},
});