Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(grout): replace jest with vitest #5764

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/grout/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.js
*.d.ts
vitest.config.ts
build
coverage
test-utils
8 changes: 0 additions & 8 deletions libs/grout/jest.config.js

This file was deleted.

13 changes: 5 additions & 8 deletions libs/grout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"lint:fix": "pnpm type-check && eslint . --fix",
"pre-commit": "lint-staged",
"test": "is-ci test:ci test:watch",
"test:ci": "jest --coverage --reporters=default --reporters=jest-junit --maxWorkers=6",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test:ci": "vitest run --coverage",
"test:coverage": "vitest --coverage",
"test:watch": "vitest",
"type-check": "tsc --build"
},
"dependencies": {
Expand All @@ -29,19 +29,16 @@
"devDependencies": {
"@types/debug": "4.1.8",
"@types/express": "4.17.14",
"@types/jest": "^29.5.3",
"@types/luxon": "^3.0.0",
"@types/node-fetch": "^2.6.0",
"@vitest/coverage-istanbul": "^2.1.8",
"eslint-plugin-vx": "workspace:*",
"expect-type": "^0.15.0",
"express": "4.18.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",
"sort-package-json": "^1.50.0",
"ts-jest": "29.1.1"
"vitest": "^2.1.8"
},
"packageManager": "[email protected]"
}
3 changes: 2 additions & 1 deletion libs/grout/src/grout.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-unused-expressions */
/* eslint-disable @typescript-eslint/require-await */
import { expect, test, vi } from 'vitest';
import { AddressInfo } from 'node:net';
import express from 'express';
import { err, ok, Result } from '@votingworks/basics';
Expand Down Expand Up @@ -83,7 +84,7 @@ test('registers Express routes for an API', async () => {
});

test('sends a 500 for unexpected errors', async () => {
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
const consoleErrorSpy = vi.spyOn(console, 'error').mockReturnValue();
const api = createApi({
async getStuff(): Promise<number> {
throw new Error('Unexpected error');
Expand Down
1 change: 1 addition & 0 deletions libs/grout/src/serialization.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { expect, test } from 'vitest';
import { Buffer } from 'node:buffer';
import { DateWithoutTime, err, ok } from '@votingworks/basics';
import { DateTime } from 'luxon';
Expand Down
3 changes: 3 additions & 0 deletions libs/grout/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.

2 changes: 1 addition & 1 deletion vitest.config.shared.mts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as vitest from 'vitest/config';
import { join } from 'node:path';

const isCI = process.env['CI'] === 'true';

export const base: vitest.ViteUserConfig = {
test: {
include: ['src/**/*.test.{ts,tsx}', 'test/**/*.test.{ts,tsx}'],
coverage: {
thresholds: {
lines: 100,
Expand Down