Skip to content

Commit d66e83b

Browse files
committed
Copy Vitest Node ESM config from Reselect
1 parent 88131a2 commit d66e83b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

packages/toolkit/vitest.config.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
import { defineConfig } from 'vitest/config'
22

3+
import path from 'path'
4+
import { fileURLToPath } from 'url'
5+
6+
// No __dirname under Node ESM
7+
const __filename = fileURLToPath(import.meta.url)
8+
const __dirname = path.dirname(__filename)
9+
310
export default defineConfig({
411
test: {
512
globals: true,
613
environment: 'jsdom',
714
setupFiles: ['./vitest.setup.js'],
815
include: ['./src/**/*.(spec|test).[jt]s?(x)'],
916
alias: {
10-
'@reduxjs/toolkit/query/react': './src/query/react/index.ts', // @remap-prod-remove-line
11-
'@reduxjs/toolkit/query': './src/query/index.ts', // @remap-prod-remove-line
12-
'@reduxjs/toolkit/react': './src/index.ts', // @remap-prod-remove-line
13-
'@reduxjs/toolkit': './src/index.ts', // @remap-prod-remove-line
17+
'@reduxjs/toolkit/query/react': path.join(
18+
__dirname,
19+
'./src/query/react/index.ts'
20+
), // @remap-prod-remove-line
21+
'@reduxjs/toolkit/query': path.join(__dirname, './src/query/index.ts'), // @remap-prod-remove-line
22+
'@reduxjs/toolkit/react': path.join(__dirname, './src/index.ts'), // @remap-prod-remove-line
23+
'@reduxjs/toolkit': path.join(__dirname, './src/index.ts'), // @remap-prod-remove-line
1424

1525
// this mapping is disabled as we want `dist` imports in the tests only to be used for "type-only" imports which don't play a role for jest
1626
//'^@reduxjs/toolkit/dist/(.*)$': '<rootDir>/src/*',
17-
'@internal/': './src/',
27+
'@internal/': path.join(__dirname, './src/'),
1828
},
1929
deps: {
2030
interopDefault: true,

0 commit comments

Comments
 (0)