diff --git a/libs/monorepo-utils/.eslintignore b/libs/monorepo-utils/.eslintignore index e2c7cf4cc8..ca254321c0 100644 --- a/libs/monorepo-utils/.eslintignore +++ b/libs/monorepo-utils/.eslintignore @@ -1,3 +1,3 @@ build coverage -jest.config.js \ No newline at end of file +vitest.config.ts \ No newline at end of file diff --git a/libs/monorepo-utils/jest.config.js b/libs/monorepo-utils/jest.config.js deleted file mode 100644 index 0c9a77bd87..0000000000 --- a/libs/monorepo-utils/jest.config.js +++ /dev/null @@ -1,8 +0,0 @@ -const shared = require('../../jest.config.shared'); - -/** - * @type {import('@jest/types').Config.InitialOptions} - */ -module.exports = { - ...shared, -}; diff --git a/libs/monorepo-utils/package.json b/libs/monorepo-utils/package.json index 4bb9abcbdf..e985826391 100644 --- a/libs/monorepo-utils/package.json +++ b/libs/monorepo-utils/package.json @@ -15,19 +15,19 @@ "lint": "pnpm type-check && eslint .", "lint:fix": "pnpm type-check && eslint . --fix", "test": "is-ci test:ci test:watch", - "test:coverage": "jest --coverage", - "test:watch": "jest --watch", - "test:ci": "jest --coverage --ci --reporters=default --reporters=jest-junit --maxWorkers=7", + "test:coverage": "vitest --coverage", + "test:watch": "vitest", + "test:ci": "vitest run --coverage", "pre-commit": "lint-staged" }, "dependencies": { "@votingworks/basics": "workspace:*" }, "devDependencies": { - "@types/jest": "^29.5.3", "@types/node": "20.16.0", "@typescript-eslint/eslint-plugin": "6.7.0", "@typescript-eslint/parser": "6.7.0", + "@vitest/coverage-istanbul": "^2.1.8", "esbuild-runner": "2.2.2", "eslint": "8.57.0", "eslint-config-prettier": "^9.0.0", @@ -38,14 +38,11 @@ "eslint-plugin-prettier": "^5.0.0", "eslint-plugin-vx": "workspace:*", "is-ci-cli": "2.2.0", - "jest": "^29.6.2", - "jest-junit": "^16.0.0", - "jest-watch-typeahead": "^2.2.2", "lint-staged": "11.0.0", "prettier": "3.0.3", "sort-package-json": "^1.50.0", - "ts-jest": "29.1.1", - "typescript": "5.6.2" + "typescript": "5.6.2", + "vitest": "^2.1.8" }, "packageManager": "pnpm@8.15.5" } diff --git a/libs/monorepo-utils/src/circleci.test.ts b/libs/monorepo-utils/src/circleci.test.ts index efa438cbdd..77486a1f18 100644 --- a/libs/monorepo-utils/src/circleci.test.ts +++ b/libs/monorepo-utils/src/circleci.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from 'vitest'; import { join } from 'node:path'; import { generateConfig } from './circleci'; import { getWorkspacePackageInfo } from './pnpm'; diff --git a/libs/monorepo-utils/src/circleci.ts b/libs/monorepo-utils/src/circleci.ts index 3d9bc0c7dc..d5d2ef7d83 100644 --- a/libs/monorepo-utils/src/circleci.ts +++ b/libs/monorepo-utils/src/circleci.ts @@ -14,7 +14,6 @@ function jobIdForRustPackageId(pkgId: string): string { function generateTestJobForNodeJsPackage( pkg: PnpmPackageInfo ): Optional { - /* istanbul ignore next */ if (!pkg.packageJson?.scripts?.['test']) { // exclude packages without tests return; @@ -98,11 +97,12 @@ function generateTestJobForRustCrate(pkgId: string): string[] { } function generateTestJobForPackage(pkg: PnpmPackageInfo): Optional { + /* istanbul ignore else - @preserve */ if (pkg.packageJson) { return generateTestJobForNodeJsPackage(pkg); } - /* istanbul ignore next */ + /* istanbul ignore next - @preserve */ throw new Error(`Unsupported package type: ${pkg.relativePath}`); } diff --git a/libs/monorepo-utils/src/dependencies.test.ts b/libs/monorepo-utils/src/dependencies.test.ts index 87c4c8bef1..3cf5916182 100644 --- a/libs/monorepo-utils/src/dependencies.test.ts +++ b/libs/monorepo-utils/src/dependencies.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from 'vitest'; import { join } from 'node:path'; import { findAllMonorepoDependencies, diff --git a/libs/monorepo-utils/src/pnpm.test.ts b/libs/monorepo-utils/src/pnpm.test.ts index 2b4308f42a..697885b3fc 100644 --- a/libs/monorepo-utils/src/pnpm.test.ts +++ b/libs/monorepo-utils/src/pnpm.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from 'vitest'; import { relative } from 'node:path'; import { getWorkspacePackageInfo, getWorkspacePackagePaths } from './pnpm'; diff --git a/libs/monorepo-utils/src/pnpm.ts b/libs/monorepo-utils/src/pnpm.ts index 184811ad99..0cab447807 100644 --- a/libs/monorepo-utils/src/pnpm.ts +++ b/libs/monorepo-utils/src/pnpm.ts @@ -12,7 +12,7 @@ function maybeReadJson(filepath: string): unknown { try { return JSON.parse(readFileSync(filepath, { encoding: 'utf-8' })); } catch { - // istanbul ignore next + /* istanbul ignore next - @preserve */ return undefined; } } diff --git a/libs/monorepo-utils/src/unused.test.ts b/libs/monorepo-utils/src/unused.test.ts index d2fb6bf563..9531cae2ea 100644 --- a/libs/monorepo-utils/src/unused.test.ts +++ b/libs/monorepo-utils/src/unused.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from 'vitest'; import { PnpmPackageInfo } from './types'; import { findUnusedPackages } from './unused'; diff --git a/libs/monorepo-utils/vitest.config.ts b/libs/monorepo-utils/vitest.config.ts new file mode 100644 index 0000000000..1cc9c7884b --- /dev/null +++ b/libs/monorepo-utils/vitest.config.ts @@ -0,0 +1,3 @@ +import { defineConfig } from '../../vitest.config.shared.mjs'; + +export default defineConfig(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4f6f7adca7..0a353c4f4c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4769,9 +4769,6 @@ importers: specifier: workspace:* version: link:../basics devDependencies: - '@types/jest': - specifier: ^29.5.3 - version: 29.5.3 '@types/node': specifier: 20.16.0 version: 20.16.0 @@ -4781,6 +4778,9 @@ importers: '@typescript-eslint/parser': specifier: 6.7.0 version: 6.7.0(eslint@8.57.0)(typescript@5.6.2) + '@vitest/coverage-istanbul': + specifier: ^2.1.8 + version: 2.1.8(vitest@2.1.8) esbuild-runner: specifier: 2.2.2 version: 2.2.2(esbuild@0.21.2) @@ -4811,15 +4811,6 @@ importers: is-ci-cli: specifier: 2.2.0 version: 2.2.0 - jest: - specifier: ^29.6.2 - version: 29.6.2(@types/node@20.16.0) - jest-junit: - specifier: ^16.0.0 - version: 16.0.0 - jest-watch-typeahead: - specifier: ^2.2.2 - version: 2.2.2(jest@29.6.2) lint-staged: specifier: 11.0.0 version: 11.0.0 @@ -4829,12 +4820,12 @@ importers: sort-package-json: specifier: ^1.50.0 version: 1.50.0 - ts-jest: - specifier: 29.1.1 - version: 29.1.1(@babel/core@7.26.0)(@jest/types@29.6.1)(esbuild@0.21.2)(jest@29.6.2)(typescript@5.6.2) typescript: specifier: 5.6.2 version: 5.6.2 + vitest: + specifier: ^2.1.8 + version: 2.1.8(@types/node@20.16.0)(jsdom@20.0.1) libs/pdi-scanner: dependencies: