forked from facebook/lexical
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.mts
More file actions
71 lines (68 loc) · 1.86 KB
/
Copy pathvitest.config.mts
File metadata and controls
71 lines (68 loc) · 1.86 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
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import tsconfigPaths from 'vite-tsconfig-paths';
import {defineConfig, mergeConfig, Plugin} from 'vitest/config';
function lexicalTestMocks(): Plugin {
return {
config(config, _env) {
return mergeConfig(config, {
resolve: {
alias: {
'shared/devInvariant':
'packages/shared/src/__mocks__/devInvariant.ts',
'shared/invariant': 'packages/shared/src/__mocks__/invariant.ts',
'shared/warnOnlyOnce':
'packages/shared/src/__mocks__/warnOnlyOnce.ts',
},
},
});
},
name: 'lexicalTestMocks',
};
}
export default defineConfig({
test: {
clearMocks: true,
projects: [
{
define: {
// https://react.dev/blog/2022/03/08/react-18-upgrade-guide#configuring-your-testing-environment
IS_REACT_ACT_ENVIRONMENT: true,
__DEV__: true,
},
extends: true,
plugins: [
tsconfigPaths({projects: ['./tsconfig.test.json']}),
lexicalTestMocks(),
],
test: {
env: {
LEXICAL_VERSION: JSON.stringify(
`${process.env.npm_package_version}+git`,
),
},
environment: 'jsdom',
include: ['packages/**/__tests__/unit/**/*.test{.ts,.tsx,.js,.jsx}'],
name: 'unit',
setupFiles: ['./vitest.setup.mts'],
typecheck: {
tsconfig: './tsconfig.test.json',
},
},
},
{
extends: true,
test: {
environment: 'node',
include: ['scripts/**/__tests__/unit/**/*.test.ts'],
name: 'scripts-unit',
},
},
],
},
});