Skip to content

Commit a47eaaa

Browse files
committed
chore(plugin): use vitest
1 parent d210fa2 commit a47eaaa

File tree

9 files changed

+158
-40
lines changed

9 files changed

+158
-40
lines changed

libs/plugin/jest.config.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

libs/plugin/project.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
}
3939
},
4040
"test": {
41-
"executor": "@nx/jest:jest",
42-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
41+
"executor": "@nx/vite:test",
42+
"outputs": ["{options.reportsDirectory}"],
4343
"options": {
44-
"jestConfig": "libs/plugin/jest.config.ts"
44+
"reportsDirectory": "../../coverage/libs/plugin"
4545
}
4646
},
4747
"publish-next": {

libs/plugin/tsconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"compilerOptions": {
4-
"module": "commonjs"
5-
},
63
"files": [],
74
"include": [],
85
"references": [

libs/plugin/tsconfig.spec.json

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../../dist/out-tsc",
5-
"module": "node16",
6-
"moduleResolution": "node16",
7-
"types": ["jest", "node"],
8-
"allowJs": true
5+
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"]
96
},
10-
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
7+
"include": [
8+
"vite.config.ts",
9+
"vite.config.mts",
10+
"vitest.config.ts",
11+
"vitest.config.mts",
12+
"src/**/*.test.ts",
13+
"src/**/*.spec.ts",
14+
"src/**/*.test.tsx",
15+
"src/**/*.spec.tsx",
16+
"src/**/*.test.js",
17+
"src/**/*.spec.js",
18+
"src/**/*.test.jsx",
19+
"src/**/*.spec.jsx",
20+
"src/**/*.d.ts"
21+
]
1122
}

libs/plugin/vite.config.mts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// <reference types="vitest" />
2+
//
3+
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
4+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
5+
import { defineConfig } from 'vite';
6+
7+
export default defineConfig({
8+
root: __dirname,
9+
cacheDir: '../../node_modules/.vite/libs/plugin',
10+
plugins: [nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
11+
// Uncomment this if you are using workers.
12+
// worker: {
13+
// plugins: [ nxViteTsPaths() ],
14+
// },
15+
test: {
16+
watch: false,
17+
globals: true,
18+
environment: 'jsdom',
19+
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
20+
reporters: ['default'],
21+
coverage: { reportsDirectory: '../../coverage/libs/plugin', provider: 'v8' },
22+
},
23+
});

nx.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
"cache": true,
7777
"dependsOn": ["^build"],
7878
"inputs": ["production", "^production"]
79+
},
80+
"@nx/vite:test": {
81+
"cache": true,
82+
"inputs": ["default", "^production"]
7983
}
8084
},
8185
"namedInputs": {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
"@types/node": "20.14.12",
5858
"@types/three": "^0.173.0",
5959
"@typescript-eslint/utils": "8.23.0",
60+
"@vitest/coverage-v8": "^1.0.4",
61+
"@vitest/ui": "^1.3.1",
6062
"autoprefixer": "^10.4.20",
6163
"cypress": "^13.17.0",
6264
"cz-git": "^1.11.0",

pnpm-lock.yaml

Lines changed: 109 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vitest.workspace.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default ['**/*/vite.config.{ts,mts}', '**/*/vitest.config.{ts,mts}'];

0 commit comments

Comments
 (0)