Skip to content

Commit

Permalink
Merge pull request #4668 from aryaemami59/modernize-vitest-config
Browse files Browse the repository at this point in the history
Modernize vitest config
  • Loading branch information
EskiMojo14 committed Jan 25, 2024
2 parents df9efdc + 848c40d commit 2107c55
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- name: Install build artifact
run: yarn add ./package.tgz

- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.json ./vitest.config.ts ./test/tsconfig.json ./test/typescript/tsconfig.json
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.json ./vitest.config.mts ./test/tsconfig.json ./test/typescript/tsconfig.json

- name: Run tests, against dist
run: yarn test
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"check-types": "tsc --noEmit && echo \"Types compiled\"",
"test": "vitest --run",
"test:types": "tsc -p test/typescript && echo \"Typetests passed\"",
"test:watch": "vitest",
"test:watch": "vitest --watch",
"test:cov": "vitest --coverage",
"test:typecheck": "tsc -p test && echo \"Types passed\"",
"build": "tsup",
Expand Down Expand Up @@ -76,7 +76,7 @@
"rxjs": "^7.5.6",
"tsup": "7.0.0",
"typescript": "5.2",
"vitest": "^0.34.0"
"vitest": "^1.2.1"
},
"resolutions": {
"esbuild": "0.19.7",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"baseUrl": "./",
"types": ["vitest/globals", "esbuild-extra/global"],
"types": ["vitest/globals", "esbuild-extra/global", "vitest/importMeta"],
"paths": {
"redux": ["src/index.ts"], // @remap-prod-remove-line
"@internal/*": ["src/*"]
Expand Down
14 changes: 9 additions & 5 deletions vitest.config.ts → vitest.config.mts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { defineConfig } from 'vitest/config'

import path from 'node:path'
import { fileURLToPath } from 'node:url'

// No __dirname under Node ESM
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

export default defineConfig({
test: {
globals: true,
include: ['./test/**/*.(spec|test).[jt]s?(x)'],
alias: {
redux: './src/index.ts', // @remap-prod-remove-line
redux: path.join(__dirname, './src/index.ts'), // @remap-prod-remove-line

// 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
'@internal/': './src/'
},
deps: {
interopDefault: true
'@internal': path.join(__dirname, 'src')
}
}
})

0 comments on commit 2107c55

Please sign in to comment.