diff --git a/libs/fs/.eslintignore b/libs/fs/.eslintignore index e2c7cf4cc8..ca254321c0 100644 --- a/libs/fs/.eslintignore +++ b/libs/fs/.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/fs/jest.config.js b/libs/fs/jest.config.js deleted file mode 100644 index 5eb3e190e5..0000000000 --- a/libs/fs/jest.config.js +++ /dev/null @@ -1,17 +0,0 @@ -const shared = require('../../jest.config.shared'); - -/** - * @type {import('@jest/types').Config.InitialOptions} - */ -module.exports = { - ...shared, - coveragePathIgnorePatterns: ['test'], - coverageThreshold: { - global: { - statements: 100, - branches: 100, - functions: 100, - lines: 100, - }, - }, -}; diff --git a/libs/fs/package.json b/libs/fs/package.json index f0061bc4ce..2d828d5e79 100644 --- a/libs/fs/package.json +++ b/libs/fs/package.json @@ -18,9 +18,9 @@ "lint:fix": "pnpm type-check && eslint . --fix", "pre-commit": "lint-staged", "test": "is-ci test:ci test:watch", - "test:ci": "pnpm build && pnpm test:coverage --reporters=default --reporters=jest-junit --maxWorkers=6", - "test:coverage": "jest --coverage", - "test:watch": "jest --watch", + "test:ci": "pnpm build && vitest run --coverage", + "test:coverage": "vitest --coverage", + "test:watch": "vitest", "type-check": "tsc --build" }, "dependencies": { @@ -35,22 +35,19 @@ }, "devDependencies": { "@types/debug": "4.1.8", - "@types/jest": "^29.5.3", "@types/node": "20.16.0", "@types/tmp": "0.2.4", + "@vitest/coverage-istanbul": "^2.1.8", "@votingworks/fixtures": "workspace:*", "@votingworks/test-utils": "workspace:*", "eslint-plugin-vx": "workspace:*", "fast-check": "2.23.2", "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", "memory-streams": "^0.1.3", "sort-package-json": "^1.50.0", "tmp": "^0.2.1", - "ts-jest": "29.1.1" + "vitest": "^2.1.8" }, "packageManager": "pnpm@8.15.5" } diff --git a/libs/fs/src/election.test.ts b/libs/fs/src/election.test.ts index d875f009f1..0214940cf0 100644 --- a/libs/fs/src/election.test.ts +++ b/libs/fs/src/election.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from 'vitest'; import { err, ok, typedAs } from '@votingworks/basics'; import { electionFamousNames2021Fixtures } from '@votingworks/fixtures'; import { writeFileSync } from 'node:fs'; diff --git a/libs/fs/src/index.ts b/libs/fs/src/index.ts index f8343997a2..4f1184ee0f 100644 --- a/libs/fs/src/index.ts +++ b/libs/fs/src/index.ts @@ -1,4 +1,4 @@ -/* istanbul ignore file */ +/* istanbul ignore file - @preserve */ export * from './election'; export * from './list_directory'; export * from './open_file'; diff --git a/libs/fs/src/list_directory.test.ts b/libs/fs/src/list_directory.test.ts index 4a08fd7f53..0696f00390 100644 --- a/libs/fs/src/list_directory.test.ts +++ b/libs/fs/src/list_directory.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, test } from 'vitest'; import { err, iter, ok } from '@votingworks/basics'; import { symlinkSync } from 'node:fs'; import tmp from 'tmp'; diff --git a/libs/fs/src/list_directory.ts b/libs/fs/src/list_directory.ts index e4f0521ad9..9d9b726ec1 100644 --- a/libs/fs/src/list_directory.ts +++ b/libs/fs/src/list_directory.ts @@ -32,7 +32,7 @@ export interface FileSystemEntry { /** * Finds the {@link FileSystemEntryType} of a directory entity. */ -/* istanbul ignore next */ +/* istanbul ignore next - @preserve */ function getDirentType(dirent: Dirent): FileSystemEntryType { if (dirent.isFile()) return FileSystemEntryType.File; if (dirent.isDirectory()) return FileSystemEntryType.Directory; @@ -84,7 +84,7 @@ export async function* listDirectory( } } catch (e) { const error = e as { code: string }; - /* istanbul ignore next */ + /* istanbul ignore next - @preserve */ switch (error.code) { case 'ENOENT': yield err({ diff --git a/libs/fs/src/open_file.test.ts b/libs/fs/src/open_file.test.ts index 78af2adbcb..94f752f5fd 100644 --- a/libs/fs/src/open_file.test.ts +++ b/libs/fs/src/open_file.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from 'vitest'; import { err } from '@votingworks/basics'; import { makeTmpFile } from '../test/utils'; import { open } from './open_file'; diff --git a/libs/fs/src/read_file.test.ts b/libs/fs/src/read_file.test.ts index a65007eb4e..420ea9a6b4 100644 --- a/libs/fs/src/read_file.test.ts +++ b/libs/fs/src/read_file.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from 'vitest'; import { Buffer } from 'node:buffer'; import { writeFileSync } from 'node:fs'; import { err, ok, typedAs } from '@votingworks/basics'; diff --git a/libs/fs/src/read_file.ts b/libs/fs/src/read_file.ts index 2c25b100fa..f314555507 100644 --- a/libs/fs/src/read_file.ts +++ b/libs/fs/src/read_file.ts @@ -68,7 +68,7 @@ export async function readFile( const buffer = Buffer.allocUnsafe(stat.size); const readResult = await fd.read(buffer, 0, stat.size, 0); - /* istanbul ignore next */ + /* istanbul ignore next - @preserve */ if (readResult.bytesRead !== stat.size) { await fd.close(); return err({ diff --git a/libs/fs/test/utils.ts b/libs/fs/test/utils.ts index 6916c268c4..60fb8ee027 100644 --- a/libs/fs/test/utils.ts +++ b/libs/fs/test/utils.ts @@ -1,3 +1,4 @@ +import { afterEach } from 'vitest'; import { unlinkSync } from 'node:fs'; import { tmpNameSync } from 'tmp'; diff --git a/libs/fs/vitest.config.ts b/libs/fs/vitest.config.ts new file mode 100644 index 0000000000..1cc9c7884b --- /dev/null +++ b/libs/fs/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 ea6bebd377..46e95aeb37 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4088,15 +4088,15 @@ importers: '@types/debug': specifier: 4.1.8 version: 4.1.8 - '@types/jest': - specifier: ^29.5.3 - version: 29.5.3 '@types/node': specifier: 20.16.0 version: 20.16.0 '@types/tmp': specifier: 0.2.4 version: 0.2.4 + '@vitest/coverage-istanbul': + specifier: ^2.1.8 + version: 2.1.8(vitest@2.1.8) '@votingworks/fixtures': specifier: workspace:* version: link:../fixtures @@ -4112,15 +4112,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 @@ -4133,9 +4124,9 @@ importers: tmp: specifier: ^0.2.1 version: 0.2.1 - ts-jest: - specifier: 29.1.1 - version: 29.1.1(@babel/core@7.26.0)(@jest/types@29.6.1)(esbuild@0.18.17)(jest@29.6.2)(typescript@5.6.2) + vitest: + specifier: ^2.1.8 + version: 2.1.8(@types/node@20.16.0)(jsdom@20.0.1) libs/fujitsu-thermal-printer: dependencies: