Skip to content

Commit 0cf4b08

Browse files
committed
Use shareable Vitest config
1 parent 9945ec6 commit 0cf4b08

File tree

3 files changed

+6
-30
lines changed

3 files changed

+6
-30
lines changed
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import { defineConfig } from 'vitest/config'
1+
import { createVitestConfig } from '@reduxjs/vitest-config'
22

3-
export default defineConfig({
4-
test: {
5-
globals: true
6-
}
7-
})
3+
export default createVitestConfig()
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1+
import { createVitestConfig } from '@reduxjs/vitest-config';
12
import path from 'node:path';
2-
import { fileURLToPath } from 'node:url';
3-
import tsconfigPaths from 'vite-tsconfig-paths';
4-
import { defineConfig } from 'vitest/config';
53

6-
// No __dirname under Node ESM
7-
const __filename = fileURLToPath(import.meta.url);
8-
const __dirname = path.dirname(__filename);
9-
10-
export default defineConfig({
11-
plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })],
4+
export default createVitestConfig({
125
test: {
136
alias: process.env.TEST_DIST
147
? {
158
'@rtk-query/codegen-openapi': path.join(__dirname, '../..', 'node_modules/@rtk-query/codegen-openapi'),
169
}
1710
: undefined,
18-
testTimeout: 10_000,
1911
pool: 'forks',
20-
globals: true,
2112
setupFiles: ['./test/vitest.setup.ts'],
2213
},
2314
});

packages/toolkit/vitest.config.mts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
import path from 'node:path'
2-
import { fileURLToPath } from 'node:url'
3-
import tsconfigPaths from 'vite-tsconfig-paths'
4-
import { defineConfig } from 'vitest/config'
1+
import { createVitestConfig } from '@reduxjs/vitest-config'
52

6-
// No __dirname under Node ESM
7-
const __filename = fileURLToPath(import.meta.url)
8-
const __dirname = path.dirname(__filename)
9-
10-
export default defineConfig({
11-
plugins: [tsconfigPaths({ root: __dirname })],
3+
export default createVitestConfig({
124
test: {
135
alias: process.env.TEST_DIST
146
? {
@@ -18,10 +10,7 @@ export default defineConfig({
1810
).pathname,
1911
}
2012
: undefined,
21-
globals: true,
2213
environment: 'jsdom',
23-
setupFiles: ['./vitest.setup.ts'],
24-
include: ['./src/**/*.(spec|test).[jt]s?(x)'],
2514
server: { deps: { inline: ['redux', '@reduxjs/toolkit'] } },
2615
},
2716
})

0 commit comments

Comments
 (0)