diff --git a/packages/nx-set-shas/README.md b/packages/nx-set-shas/README.md index 4ba842c0..56fc7911 100644 --- a/packages/nx-set-shas/README.md +++ b/packages/nx-set-shas/README.md @@ -8,4 +8,4 @@ Run `nx build nx-set-shas` to build the library. ## Running unit tests -Run `nx test nx-set-shas` to execute the unit tests via [Jest](https://jestjs.io). +Run `nx test nx-set-shas` to execute the unit tests via [Vitest](https://vitest.dev/). diff --git a/packages/nx-set-shas/eslint.config.js b/packages/nx-set-shas/eslint.config.js index 9d2af7a3..a1ce51bb 100644 --- a/packages/nx-set-shas/eslint.config.js +++ b/packages/nx-set-shas/eslint.config.js @@ -8,7 +8,7 @@ module.exports = [ '@nx/dependency-checks': [ 'error', { - ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'], + ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}', '{projectRoot}/vite.config.{js,ts,mjs,mts}'], }, ], }, diff --git a/packages/nx-set-shas/jest.config.ts b/packages/nx-set-shas/jest.config.ts deleted file mode 100644 index 1c6b1147..00000000 --- a/packages/nx-set-shas/jest.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -export default { - displayName: 'nx-set-shas', - preset: '../../jest.preset.js', - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: 'test-output/jest/coverage', -}; diff --git a/packages/nx-set-shas/project.json b/packages/nx-set-shas/project.json index 8fdc4b5c..a7760e47 100644 --- a/packages/nx-set-shas/project.json +++ b/packages/nx-set-shas/project.json @@ -4,6 +4,13 @@ "sourceRoot": "packages/nx-set-shas/src", "projectType": "library", "tags": ["type:cli", "scope:nx-set-shas"], - "// targets": "to see all targets run: nx show project nx-set-shas --web", - "targets": {} + "targets": { + "test": { + "executor": "@nx/vite:test", + "outputs": ["{options.reportsDirectory}"], + "options": { + "reportsDirectory": "../../coverage/packages/nx-set-shas" + } + } + } } diff --git a/packages/nx-set-shas/tsconfig.lib.json b/packages/nx-set-shas/tsconfig.lib.json index d672cab3..e73113a8 100644 --- a/packages/nx-set-shas/tsconfig.lib.json +++ b/packages/nx-set-shas/tsconfig.lib.json @@ -10,10 +10,19 @@ "resolveJsonModule": true }, "include": ["src/**/*.ts"], - "references": [ - { - "path": "../core/tsconfig.lib.json" - } - ], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] + "references": [], + "exclude": [ + "vite.config.ts", + "vite.config.mts", + "vitest.config.ts", + "vitest.config.mts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx" + ] } diff --git a/packages/nx-set-shas/tsconfig.spec.json b/packages/nx-set-shas/tsconfig.spec.json index c67ac295..8c71d9e6 100644 --- a/packages/nx-set-shas/tsconfig.spec.json +++ b/packages/nx-set-shas/tsconfig.spec.json @@ -1,10 +1,24 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./out-tsc/jest", - "types": ["jest", "node"] + "outDir": "./out-tsc/vitest", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"] }, - "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"], + "include": [ + "vite.config.ts", + "vite.config.mts", + "vitest.config.ts", + "vitest.config.mts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ], "references": [ { "path": "./tsconfig.lib.json" diff --git a/packages/nx-set-shas/vite.config.ts b/packages/nx-set-shas/vite.config.ts new file mode 100644 index 00000000..1b2ffe68 --- /dev/null +++ b/packages/nx-set-shas/vite.config.ts @@ -0,0 +1,19 @@ +import { defineConfig } from 'vite'; + +export default defineConfig({ + root: __dirname, + cacheDir: '../../node_modules/.vite/packages/nx-set-shas', + plugins: [], + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + test: { + watch: false, + globals: true, + environment: 'node', + include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + reporters: ['default'], + coverage: { reportsDirectory: '../../coverage/packages/nx-set-shas', provider: 'v8' }, + }, +});