Skip to content

Commit

Permalink
Switch from jest to vitest 🚀 (#4628)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber authored Mar 5, 2025
1 parent 097f8b9 commit 83321cb
Show file tree
Hide file tree
Showing 132 changed files with 2,232 additions and 3,142 deletions.
9 changes: 3 additions & 6 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 @@ -35,11 +35,8 @@ jobs:
- name: Run tsc build
run: yarn buildTsc

- name: Run tsc buildTests
run: yarn lerna run buildTests

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

eslint:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig"
"editorconfig.editorconfig",
"vitest.explorer"
]
}
31 changes: 0 additions & 31 deletions .vscode/launch.json
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
12 changes: 7 additions & 5 deletions adminSiteClient/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import {
SENTRY_ADMIN_DSN,
} from "../settings/clientSettings.js"

Sentry.init({
dsn: SENTRY_ADMIN_DSN,
environment: ENV,
release: COMMIT_SHA,
})
if (!process.env.VITEST) {
Sentry.init({
dsn: SENTRY_ADMIN_DSN,
environment: ENV,
release: COMMIT_SHA,
})
}
Loading

0 comments on commit 83321cb

Please sign in to comment.