diff --git a/packages/rtk-codemods/package.json b/packages/rtk-codemods/package.json index f970e826ac..a2e25601d9 100644 --- a/packages/rtk-codemods/package.json +++ b/packages/rtk-codemods/package.json @@ -36,6 +36,7 @@ "@reduxjs/prettier-config": "workspace:^", "@reduxjs/toolkit": "workspace:^", "@reduxjs/tsconfig": "workspace:^", + "@reduxjs/vitest-config": "workspace:^", "@types/jscodeshift": "^0.11.11", "eslint": "^9.12.0", "jiti": "^2.3.3", diff --git a/packages/rtk-codemods/vitest.config.mts b/packages/rtk-codemods/vitest.config.mts index 556ad64883..c512210fa9 100644 --- a/packages/rtk-codemods/vitest.config.mts +++ b/packages/rtk-codemods/vitest.config.mts @@ -1,7 +1,3 @@ -import { defineConfig } from 'vitest/config' +import { createVitestConfig } from '@reduxjs/vitest-config' -export default defineConfig({ - test: { - globals: true - } -}) +export default createVitestConfig() diff --git a/packages/rtk-query-codegen-openapi/package.json b/packages/rtk-query-codegen-openapi/package.json index 18e6e80fb2..bfe4aafd22 100644 --- a/packages/rtk-query-codegen-openapi/package.json +++ b/packages/rtk-query-codegen-openapi/package.json @@ -55,6 +55,7 @@ "@reduxjs/prettier-config": "workspace:^", "@reduxjs/toolkit": "^1.6.0", "@reduxjs/tsconfig": "workspace:^", + "@reduxjs/vitest-config": "workspace:^", "@types/commander": "^2.12.2", "@types/glob-to-regexp": "^0.4.0", "@types/lodash.camelcase": "^4.3.9", @@ -72,7 +73,6 @@ "rimraf": "^5.0.5", "ts-node": "^10.9.2", "tsup": "^8.2.4", - "vite-tsconfig-paths": "^5.0.1", "vitest": "^2.0.5", "yalc": "^1.0.0-pre.47" }, diff --git a/packages/rtk-query-codegen-openapi/vitest.config.mts b/packages/rtk-query-codegen-openapi/vitest.config.mts index de73ff27d2..b9ba97062e 100644 --- a/packages/rtk-query-codegen-openapi/vitest.config.mts +++ b/packages/rtk-query-codegen-openapi/vitest.config.mts @@ -1,23 +1,13 @@ -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import tsconfigPaths from 'vite-tsconfig-paths'; -import { defineConfig } from 'vitest/config'; +import { createVitestConfig } from '@reduxjs/vitest-config'; -// No __dirname under Node ESM -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -export default defineConfig({ - plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })], +export default createVitestConfig({ test: { alias: process.env.TEST_DIST ? { - '@rtk-query/codegen-openapi': path.join(__dirname, '../..', 'node_modules/@rtk-query/codegen-openapi'), + '@rtk-query/codegen-openapi': new URL('../../node_modules/@rtk-query/codegen-openapi', import.meta.url) + .pathname, } : undefined, - testTimeout: 10_000, - pool: 'forks', - globals: true, setupFiles: ['./test/vitest.setup.ts'], }, }); diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index c47a75e6b2..20f18a97b6 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -57,6 +57,7 @@ "@reduxjs/eslint-config": "workspace:^", "@reduxjs/prettier-config": "workspace:^", "@reduxjs/tsconfig": "workspace:^", + "@reduxjs/vitest-config": "workspace:^", "@size-limit/file": "^11.0.1", "@size-limit/webpack": "^11.0.1", "@testing-library/react": "^13.3.0", @@ -90,7 +91,6 @@ "tsup": "^8.2.3", "tsx": "^4.19.0", "typescript": "^5.5.4", - "vite-tsconfig-paths": "^4.3.1", "vitest": "^1.6.0", "yargs": "^15.3.1" }, diff --git a/packages/toolkit/vitest.config.mts b/packages/toolkit/vitest.config.mts index 6327d7e388..2fe505f6e1 100644 --- a/packages/toolkit/vitest.config.mts +++ b/packages/toolkit/vitest.config.mts @@ -1,14 +1,6 @@ -import path from 'node:path' -import { fileURLToPath } from 'node:url' -import tsconfigPaths from 'vite-tsconfig-paths' -import { defineConfig } from 'vitest/config' +import { createVitestConfig } from '@reduxjs/vitest-config' -// No __dirname under Node ESM -const __filename = fileURLToPath(import.meta.url) -const __dirname = path.dirname(__filename) - -export default defineConfig({ - plugins: [tsconfigPaths({ root: __dirname })], +export default createVitestConfig({ test: { alias: process.env.TEST_DIST ? { @@ -18,10 +10,7 @@ export default defineConfig({ ).pathname, } : undefined, - globals: true, environment: 'jsdom', - setupFiles: ['./vitest.setup.ts'], - include: ['./src/**/*.(spec|test).[jt]s?(x)'], server: { deps: { inline: ['redux', '@reduxjs/toolkit'] } }, }, }) diff --git a/yarn.lock b/yarn.lock index f8423f84fa..30511137a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6584,6 +6584,7 @@ __metadata: "@reduxjs/prettier-config": "workspace:^" "@reduxjs/toolkit": "workspace:^" "@reduxjs/tsconfig": "workspace:^" + "@reduxjs/vitest-config": "workspace:^" "@types/jscodeshift": "npm:^0.11.11" eslint: "npm:^9.12.0" execa: "npm:^8.0.1" @@ -6671,6 +6672,7 @@ __metadata: "@reduxjs/eslint-config": "workspace:^" "@reduxjs/prettier-config": "workspace:^" "@reduxjs/tsconfig": "workspace:^" + "@reduxjs/vitest-config": "workspace:^" "@size-limit/file": "npm:^11.0.1" "@size-limit/webpack": "npm:^11.0.1" "@testing-library/react": "npm:^13.3.0" @@ -6708,7 +6710,6 @@ __metadata: tsup: "npm:^8.2.3" tsx: "npm:^4.19.0" typescript: "npm:^5.5.4" - vite-tsconfig-paths: "npm:^4.3.1" vitest: "npm:^1.6.0" yargs: "npm:^15.3.1" peerDependencies: @@ -6728,7 +6729,7 @@ __metadata: languageName: unknown linkType: soft -"@reduxjs/vitest-config@workspace:packages/configs/vitest": +"@reduxjs/vitest-config@workspace:^, @reduxjs/vitest-config@workspace:packages/configs/vitest": version: 0.0.0-use.local resolution: "@reduxjs/vitest-config@workspace:packages/configs/vitest" dependencies: @@ -6979,6 +6980,7 @@ __metadata: "@reduxjs/prettier-config": "workspace:^" "@reduxjs/toolkit": "npm:^1.6.0" "@reduxjs/tsconfig": "workspace:^" + "@reduxjs/vitest-config": "workspace:^" "@types/commander": "npm:^2.12.2" "@types/glob-to-regexp": "npm:^0.4.0" "@types/lodash.camelcase": "npm:^4.3.9" @@ -7003,7 +7005,6 @@ __metadata: ts-node: "npm:^10.9.2" tsup: "npm:^8.2.4" typescript: "npm:^5.5.4" - vite-tsconfig-paths: "npm:^5.0.1" vitest: "npm:^2.0.5" yalc: "npm:^1.0.0-pre.47" bin: @@ -27715,22 +27716,6 @@ __metadata: languageName: node linkType: hard -"vite-tsconfig-paths@npm:^4.3.1": - version: 4.3.2 - resolution: "vite-tsconfig-paths@npm:4.3.2" - dependencies: - debug: "npm:^4.1.1" - globrex: "npm:^0.1.2" - tsconfck: "npm:^3.0.3" - peerDependencies: - vite: "*" - peerDependenciesMeta: - vite: - optional: true - checksum: 10/c12e2087fd01ac8a694850c649b79d5b9798cdba0ef9ab4116f669d8ffa1a9a3195c5a14410d3d9a12d2f08cd35ddd74f03d9c7b13a2d590d002055cdaab45c0 - languageName: node - linkType: hard - "vite-tsconfig-paths@npm:^5.0.1": version: 5.0.1 resolution: "vite-tsconfig-paths@npm:5.0.1"