Skip to content

Commit

Permalink
Use the shareable Vitest config
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Sep 26, 2024
1 parent a44728c commit 342fa27
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 54 deletions.
1 change: 1 addition & 0 deletions packages/rtk-codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.11.1",
"jiti": "^2.0.0",
Expand Down
8 changes: 2 additions & 6 deletions packages/rtk-codemods/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { defineConfig } from 'vitest/config'
import { createVitestConfig } from '@reduxjs/vitest-config'

export default defineConfig({
test: {
globals: true
}
})
export default createVitestConfig()
2 changes: 1 addition & 1 deletion packages/rtk-query-codegen-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
18 changes: 4 additions & 14 deletions packages/rtk-query-codegen-openapi/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -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'],
},
});
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
},
Expand Down
15 changes: 2 additions & 13 deletions packages/toolkit/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -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
? {
Expand All @@ -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'] } },
},
})
23 changes: 4 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6571,6 +6571,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.11.1"
execa: "npm:^8.0.1"
Expand Down Expand Up @@ -6658,6 +6659,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"
Expand Down Expand Up @@ -6695,7 +6697,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:
Expand All @@ -6715,7 +6716,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:
Expand Down Expand Up @@ -6966,6 +6967,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"
Expand All @@ -6990,7 +6992,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:
Expand Down Expand Up @@ -27702,22 +27703,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"
Expand Down

0 comments on commit 342fa27

Please sign in to comment.