Skip to content

Commit

Permalink
test(fs): replace jest with vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
eventualbuddha committed Dec 16, 2024
1 parent 62f1ce4 commit 62a634c
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 45 deletions.
2 changes: 1 addition & 1 deletion libs/fs/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build
coverage
jest.config.js
vitest.config.ts
17 changes: 0 additions & 17 deletions libs/fs/jest.config.js

This file was deleted.

13 changes: 5 additions & 8 deletions libs/fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": "[email protected]"
}
1 change: 1 addition & 0 deletions libs/fs/src/election.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion libs/fs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* istanbul ignore file */
/* istanbul ignore file - @preserve */
export * from './election';
export * from './list_directory';
export * from './open_file';
Expand Down
1 change: 1 addition & 0 deletions libs/fs/src/list_directory.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions libs/fs/src/list_directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand Down
1 change: 1 addition & 0 deletions libs/fs/src/open_file.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import { err } from '@votingworks/basics';
import { makeTmpFile } from '../test/utils';
import { open } from './open_file';
Expand Down
1 change: 1 addition & 0 deletions libs/fs/src/read_file.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion libs/fs/src/read_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
1 change: 1 addition & 0 deletions libs/fs/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { afterEach } from 'vitest';
import { unlinkSync } from 'node:fs';
import { tmpNameSync } from 'tmp';

Expand Down
3 changes: 3 additions & 0 deletions libs/fs/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineConfig } from '../../vitest.config.shared.mjs';

export default defineConfig();
21 changes: 6 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 62a634c

Please sign in to comment.