forked from KelvinTegelaar/CIPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.mjs
More file actions
103 lines (100 loc) · 3.27 KB
/
Copy pathvitest.config.mjs
File metadata and controls
103 lines (100 loc) · 3.27 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
import { defineConfig } from 'vitest/config'
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin'
import { playwright } from '@vitest/browser-playwright'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const dirname = path.dirname(fileURLToPath(import.meta.url))
const nextAliases = {
// stub for mui-tiptap's uninstalled required peer, see mocks/tiptap-extension-image.js
'@tiptap/extension-image': path.resolve(dirname, 'tests/mocks/tiptap-extension-image.js'),
'next/dynamic': path.resolve(dirname, 'tests/mocks/next-dynamic.js'),
'next/router': path.resolve(dirname, 'tests/mocks/next-router.js'),
'next/navigation': path.resolve(dirname, 'tests/mocks/next-navigation.js'),
'next/head': path.resolve(dirname, 'tests/mocks/next-head.js'),
'next/image': path.resolve(dirname, 'tests/mocks/next-image.js'),
'next/link': path.resolve(dirname, 'tests/mocks/next-link.js'),
}
export default defineConfig({
esbuild: {
jsx: 'automatic',
jsxImportSource: 'react',
loader: 'jsx',
include: /(src|tests|\.storybook)\/.*\.(js|jsx)$/,
exclude: [],
},
resolve: { alias: nextAliases },
define: { 'process.env': '{}' },
test: {
globals: true,
coverage: {
provider: 'v8',
reporter: ['text', 'text-summary'],
reportsDirectory: './coverage',
include: ['src/**/*.{js,jsx}'],
exclude: ['src/components/**/index.js'],
},
projects: [
{
resolve: { alias: nextAliases },
define: { 'process.env': '{}' },
esbuild: {
jsx: 'automatic',
jsxImportSource: 'react',
loader: 'jsx',
include: /(src|tests|\.storybook)\/.*\.(js|jsx)$/,
exclude: [],
},
test: {
name: 'unit',
environment: 'jsdom',
globals: true,
setupFiles: ['./vitest.setup.js'],
include: ['tests/**/*.test.{js,jsx}'],
css: false,
teardownTimeout: 5000,
forceExit: true,
},
},
{
plugins: [storybookTest({ configDir: path.resolve(dirname, '.storybook') })],
resolve: { alias: nextAliases },
define: { 'process.env': '{}' },
optimizeDeps: {
include: [
'react',
'react-dom',
'react/jsx-dev-runtime',
'react-redux',
'@reduxjs/toolkit',
'@tanstack/react-query',
'@mui/material/styles',
'@mui/material',
'@mui/system',
'material-react-table',
'msw/browser',
'msw-storybook-addon/csf3',
],
esbuildOptions: {
jsx: 'automatic',
loader: { '.js': 'jsx' },
},
},
test: {
name: 'storybook',
globals: true,
setupFiles: ['./.storybook/vitest.setup.js'],
browser: {
enabled: true,
provider: playwright(),
headless: true,
// dockerized runs (cipp-storybook) have the default 64MB /dev/shm, which
// chromium exhausts on heavier story trees and dies mid-run - use /tmp
instances: [
{ browser: 'chromium', launch: { args: ['--disable-dev-shm-usage'] } },
],
},
},
},
],
},
})