-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathvitest.config.ts
More file actions
76 lines (72 loc) · 2.33 KB
/
Copy pathvitest.config.ts
File metadata and controls
76 lines (72 loc) · 2.33 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
// Copyright (c) Meta Platforms, Inc. and affiliates.
/**
* @file vitest.config.ts
* @input Uses vitest/config, @vitejs/plugin-react
* @output Vitest configuration with jsdom, coverage, and test setup
* @position Root test config; applies to all packages in monorepo
*
* SYNC: When modified, update this header and root README.md
*/
import path from 'path';
import {defineConfig} from 'vitest/config';
import react from '@vitejs/plugin-react';
const rootDir = path.resolve(__dirname, '.');
const coreSrc = path.resolve(__dirname, 'packages/core/src');
export default defineConfig({
plugins: [
react({
babel: {
plugins: [
[
'@stylexjs/babel-plugin',
{
dev: true,
runtimeInjection: true,
genConditionalClasses: true,
treeshakeCompensation: true,
aliases: {
'@astryxdesign/core/*': [path.join(rootDir, 'packages/core/src/*')],
'@astryxdesign/core': [path.join(rootDir, 'packages/core/src')],
},
unstable_moduleResolution: {
type: 'commonJS',
rootDir: rootDir,
},
},
],
],
},
}),
],
resolve: {
alias: [
// Map @astryxdesign/core subpath imports to source for lab package tests.
// Must use regex to match subpaths like @astryxdesign/core/Dialog, @astryxdesign/core/theme/tokens.stylex
// while not breaking core's own relative imports.
{find: /^@astryxdesign\/core\/(.*)$/, replacement: path.join(coreSrc, '$1')},
],
},
test: {
globals: true,
environment: 'jsdom',
include: [
'packages/**/src/**/*.test.{ts,tsx,mjs}',
'internal/**/*.test.{ts,tsx,mjs}',
'scripts/**/*.test.{ts,tsx,mjs}',
],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
include: ['packages/**/src/**/*.{ts,tsx}'],
exclude: ['**/*.test.{ts,tsx}', '**/*.stories.{ts,tsx}', '**/index.ts'],
},
setupFiles: ['./internal/test-utils/src/setup.ts'],
// Increase worker heap to prevent OOM crashes on memory-heavy test files
// (e.g. Chat composer tests with contentEditable + popover portals in jsdom).
poolOptions: {
forks: {
execArgv: ['--max-old-space-size=4096'],
},
},
},
});