-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
127 lines (124 loc) · 3.36 KB
/
vitest.config.ts
File metadata and controls
127 lines (124 loc) · 3.36 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { defineConfig, type Plugin } from "vitest/config";
import path from "node:path";
/** Stub `?iife` imports in tests — returns an empty string instead of file contents. */
function iifeStub(): Plugin {
return {
name: "iife-stub",
resolveId(source) {
if (source.endsWith("?iife")) {
return `\0${source}`;
}
return null;
},
load(id) {
if (id.startsWith("\0") && id.endsWith("?iife")) {
return "export default ''; export const filename = 'stub.worker.js';";
}
return null;
},
};
}
const sharedResolve = {
dedupe: ["wagmi", "react", "react-dom", "@tanstack/react-query"],
alias: [
{
find: /^@zama-fhe\/sdk\/cleartext$/,
replacement: path.resolve(__dirname, "./packages/sdk/src/relayer/cleartext/index.ts"),
},
{
find: /^@zama-fhe\/sdk\/(.+)/,
replacement: path.resolve(__dirname, "./packages/sdk/src/$1"),
},
{
find: "@zama-fhe/sdk",
replacement: path.resolve(__dirname, "./packages/sdk/src"),
},
{
find: /^@zama-fhe\/react-sdk\/(.+)/,
replacement: path.resolve(__dirname, "./packages/react-sdk/src/$1"),
},
{
find: /^@zama-fhe\/react-sdk$/,
replacement: path.resolve(__dirname, "./packages/react-sdk/src"),
},
{
find: /^wagmi\/actions$/,
replacement: path.resolve(
__dirname,
"./packages/react-sdk/node_modules/wagmi/dist/esm/exports/actions.js",
),
},
{
find: /^wagmi$/,
replacement: path.resolve(
__dirname,
"./packages/react-sdk/node_modules/wagmi/dist/esm/exports/index.js",
),
},
],
};
export default defineConfig({
test: {
projects: [
{
plugins: [iifeStub()],
test: {
name: "sdk",
environment: "node",
pool: "vmForks",
include: ["packages/sdk/**/*.test.{ts,tsx}"],
exclude: ["**/*integration.test.ts", "**/node_modules/**", "**/worker/__tests__/**"],
globals: true,
setupFiles: ["./vitest.setup.ts"],
},
resolve: sharedResolve,
},
{
test: {
name: "typecheck",
include: ["packages/sdk/**/*.test-d.ts"],
typecheck: {
enabled: true,
tsconfig: "./packages/sdk/tsconfig.json",
},
},
resolve: sharedResolve,
},
{
plugins: [iifeStub()],
test: {
name: "react-sdk",
environment: "happy-dom",
pool: process.env.CI ? "forks" : "vmForks",
include: [
"packages/react-sdk/**/*.test.{ts,tsx}",
"packages/sdk/src/worker/__tests__/*.test.ts",
],
exclude: ["**/*integration.test.ts", "**/node_modules/**"],
globals: true,
setupFiles: ["./vitest.setup.ts"],
},
resolve: sharedResolve,
},
],
coverage: {
provider: "v8",
reporter: ["text", "json", "json-summary", "html"],
include: ["packages/sdk/src/**", "packages/react-sdk/src/**"],
exclude: [
"**/__tests__/**",
"**/*.test.{ts,tsx}",
"**/*.types.ts",
"**/abi/**",
"**/index.ts",
"**/worker/relayer-sdk.worker.ts",
"**/worker/relayer-sdk.node-worker.ts",
],
thresholds: {
lines: 80,
branches: 80,
functions: 80,
},
},
},
});