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

Vitest 🚀 #4628

Merged
merged 36 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
19d9e94
chore(deps): remove jest
marcelgerber Mar 5, 2025
9b40e71
chore(deps): remove enzyme
marcelgerber Mar 5, 2025
63359cd
chore(deps): add vitest
marcelgerber Mar 5, 2025
21b4d1e
wip: most tests work with vitest
marcelgerber Mar 5, 2025
b1c354b
chore(deps): update testing-library
marcelgerber Mar 5, 2025
6f0fb6a
wip: use happy-dom for all test that used to be jsdom
marcelgerber Mar 5, 2025
ca1f6e2
chore: rename all `.jsdom.test` files
marcelgerber Mar 5, 2025
a8e2e2e
wip: replace jest mocks & spy's with vitest
marcelgerber Mar 5, 2025
83c2806
wip: fix types
marcelgerber Mar 5, 2025
f5faa20
chore(deps): add back enzyme, fix cheerio types
marcelgerber Mar 5, 2025
763bec6
wip: fix Util test
marcelgerber Mar 5, 2025
06d0b14
chore: get cheerio right
marcelgerber Mar 5, 2025
f910ca1
chore: use jsdom over happy-dom
marcelgerber Mar 5, 2025
b4f35bb
fix test case
marcelgerber Mar 5, 2025
c6830a5
disable a bunch of failing tests (related to mocking)
marcelgerber Mar 5, 2025
fa57638
chore(ci): change ci commands
marcelgerber Mar 5, 2025
d6e83df
chore: remove unnecessary imports
marcelgerber Mar 5, 2025
fa90962
enhance: enable db tests
marcelgerber Mar 5, 2025
5038333
fix: fix app test failing
marcelgerber Mar 5, 2025
63ee34a
chore(deps): install @vitest/coverage-v8
marcelgerber Mar 5, 2025
f9174c9
remove remaining jest uses
marcelgerber Mar 5, 2025
f0531e6
a few changes
marcelgerber Mar 5, 2025
912cee5
chore(deps): move yargs
marcelgerber Mar 5, 2025
f06411c
chore: use test environment node where possible
marcelgerber Mar 5, 2025
d1c30e9
merge the two Marimekko test suites
marcelgerber Mar 5, 2025
1fa5fdf
chore(deps): remove `@testing-library/dom` again
marcelgerber Mar 5, 2025
f5694dd
chore: rename test files `.tsx` to `.ts` if they aren't JSX
marcelgerber Mar 5, 2025
e016695
enhance: extend default vite config
marcelgerber Mar 5, 2025
9eb52aa
enhance: disable some plugins in vitest
marcelgerber Mar 5, 2025
f176378
enhance: split `redirects` file in two so we can properly mock it
marcelgerber Mar 5, 2025
2538474
enhance: re-enable pageOverrides tests
marcelgerber Mar 5, 2025
5c845af
docs: remove outdated comment
marcelgerber Mar 5, 2025
37253cd
chore(deps): update @testing-library/jest-dom
marcelgerber Mar 5, 2025
072bd49
chore(ci): add back tsc build
marcelgerber Mar 5, 2025
29b0bc1
enhance: add vitest extension to recommended extensions
marcelgerber Mar 5, 2025
ac0fa7a
enhance: don't init sentry when running vitest
marcelgerber Mar 5, 2025
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
12 changes: 3 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Continuous Integration
on: [push, pull_request]

jobs:
# Checks for prettify errors, TypeScript errors and runs Jest tests.
# Checks for prettify errors, TypeScript errors and runs vitest tests.
testdbcheck:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -32,14 +32,8 @@ jobs:
- name: Run prettier
run: yarn testPrettierAll

- name: Run tsc build
run: yarn buildTsc

- name: Run tsc buildTests
run: yarn lerna run buildTests
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added side effect: The istJustJavascript and dist/tests dirs are pretty much things of the past.
I haven't entirely gone rid of them at this point, but we're pretty close now!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I last looked into this, i.e. when I introduced tsx, the main reason to keep istJustJavascript was that tsx runs esbuild every time, so we pay the cost of the transpilation on every restart of the process, e.g. the admin server, and also I wasn't sure how much ongoing overhead it incurs during runtime.

I'm now more inclined to think it would be fine to use it in prod, but it warrants more investigation. See also their FAQ.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - this is certainly not something I want to change in this PR :)

Was just thinking that jest was one of the main consumers of itsJustJavascript, and that's now gone.


- name: Run jest
run: yarn testJest
- name: Run vitest
run: yarn test

eslint:
runs-on: ubuntu-latest
Expand Down
31 changes: 0 additions & 31 deletions .vscode/launch.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a Vitest configuration shared across the team would be nice. Could we add one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sure, although I must say that I don't really use Launch configurations myself.
I'm also gonna share the vitest VS Code extension, which is really quite cool and useful!
But, feel free to add a launch config yourself, if you feel like it.

Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,6 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"args": [],
"internalConsoleOptions": "openOnSessionStart",
"name": "Jest Tests",
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
//somewhat unstable, WIP
"type": "node",
"request": "launch",
"name": "Jest Test current file",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}.js",
"--watch"
],
"args": [
"${fileBasenameNoExtension}.js",
"--watch"
],
"console": "integratedTerminal"
// "internalConsoleOptions": "neverOpen"
},
{
"name": "Launch site dev",
"program": "${workspaceFolder}/itsJustJavascript/adminSiteServer/app.js",
Expand Down
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,14 @@ tmp-downloads/owid_metadata.sql.gz:
test: node_modules
@echo '==> Linting'
yarn run eslint
yarn lerna run build
yarn lerna run buildTests

@echo '==> Checking formatting'
yarn testPrettierAll

@echo '==> Running tests'
yarn run jest
yarn run test

dbtest: node_modules
@echo '==> Building'
yarn buildTsc

@echo '==> Running db test script'
./db/tests/run-db-tests.sh

Expand All @@ -254,7 +249,7 @@ format: node_modules

unittest: node_modules
@echo '==> Running tests'
yarn run jest --all
yarn run test

../owid-grapher-svgs:
cd .. && git clone [email protected]:owid/owid-grapher-svgs
Expand Down
2 changes: 1 addition & 1 deletion adminShared/SqlFilterSExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env jest
import { expect, it, describe } from "vitest"
import { variableAnnotationAllowedColumnNamesAndTypes } from "./AdminSessionTypes.js"
import {
parseToOperation,
Expand Down
2 changes: 1 addition & 1 deletion adminShared/patchHelper.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env jest
import { expect, it } from "vitest"

import { setValueRecursive, setValueRecursiveInplace } from "./patchHelper.js"

Expand Down
Loading