-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathvitest.config.mts
More file actions
34 lines (32 loc) · 1.12 KB
/
Copy pathvitest.config.mts
File metadata and controls
34 lines (32 loc) · 1.12 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
import { createRequire } from 'module';
import { dirname, resolve } from 'path';
import { versionInfo } from 'graphql';
import { defineConfig } from 'vitest/config';
export const sharedConfig = defineConfig({
resolve: {
alias: {
graphql: (function resolveGraphQL() {
if (versionInfo.major < 17) {
return 'graphql/index.js';
}
// Use an absolute path to graphql/index.mjs so ALL imports (Vite-processed
// and Node.js-native) resolve to the same ESM module in Node.js's module cache,
// preventing graphql@17's devInstanceOf from detecting false cross-realm usage.
const _require = createRequire(import.meta.url);
// require.resolve('graphql') returns index.mjs in Node.js v24 (via module-sync condition)
const graphqlIndexMjs = resolve(dirname(_require.resolve('graphql')), 'index.mjs');
return graphqlIndexMjs;
})(),
},
tsconfigPaths: true,
},
test: {
globals: true,
},
});
export default defineConfig({
test: {
projects: ['packages/**/vitest.config.mts', 'examples/**/vitest.config.mts'],
watch: false,
},
});