Skip to content

Commit

Permalink
Switch from Jest to Vitest (#273)
Browse files Browse the repository at this point in the history
* start switch to vitest

* drop jest stuff, other dirname and import dep fixes, reset lerna.json

* use default-import to use and extend rbush

* add vitest dep formally, add vitest-setup loading jest-dom

* Migrate more tests, make them runnable standalone in vscode debug with direct import

* update geoblaze, update overlap output changes related to turf area. skip many remaining tests

* fix prepare

* comment out and skip tests with jest mocks

* initial migrate of scripts to vitest, skipping failing precalc datasource tests

* stub vitest project runner

* clean up vitest config type error, and punt on browser test mock error and bump vi* versions

* skip remaining failing tests, add back test commit gate

* try making vitest regular dependency

* update runner to config project vitest

* merge cli options

* fix vitest cli command

* switch to TEST_ROOT env var

* shift jsdom dep for project use

* fix TEST_ROOT

* simplify test commands, tune test config

* update vitest comments

* add data server back to test command

* vitest comments

* drop ts-node for tsx

* add testing of base and template packages, skipping most.  Migrate remaining commands to vitest. Migrate to turf 7 in projects
  • Loading branch information
twelch authored Apr 2, 2024
1 parent 001c32d commit 00362ec
Show file tree
Hide file tree
Showing 98 changed files with 12,419 additions and 4,977 deletions.
3 changes: 2 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
. "$(dirname -- "$0")/_/husky.sh"

npx lerna run prepare # transpiles core geoprocessing code for templates
# npx lerna run test:local # tests all packages including e2e tests not run by Github CI (GDAL, etc.)
# run tests including e2e tests not run by Github CI (GDAL, etc.)
npx lerna run test:local
83 changes: 41 additions & 42 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,39 @@
"configurations": [

{
"name": "geoprocessing - debug tests",
"name": "geoprocessing - debug src tests",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/geoprocessing",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/jest",
"--group=-e2e"
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/vitest",
"-c",
"vitest.config.node.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}, {
"name": "geoprocessing - debug tests with pattern",
"type": "node",
"request": "launch",
"name": "geoprocessing - debug current test file",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
}, {
"name": "geoprocessing - debug src tests with pattern",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/geoprocessing",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/jest",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/vitest",
"-c",
"vitest.config.node.js",
"-t",
"${input:testNamePattern}"
],
Expand All @@ -34,80 +47,66 @@
"port": 9229
},
{
"name": "geoprocessing - debug tests scripts",
"name": "geoprocessing - debug scripts tests",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/geoprocessing",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/jest",
"--projects",
"scripts"
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/vitest",
"-c",
"vitest.config.scripts.node.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}, {
"name": "geoprocessing - debug tests scripts with pattern",
"name": "geoprocessing - debug scripts tests with pattern",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/geoprocessing",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/jest",
"--projects",
"scripts",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/vitest",
"-c",
"vitest.config.scripts.node.js",
"-t",
"${input:testNamePattern}"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}, {
"name": "geoprocessing - debug e2e tests",
"name": "geoprocessing - debug src e2e tests",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/geoprocessing",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/jest",
"--runInBand",
"--group=e2e"
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/vitest",
"-c",
"vitest.config.e2e.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}, {
"name": "geoprocessing - debug e2e tests with pattern",
"name": "geoprocessing - debug src e2e tests with pattern",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/geoprocessing",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/jest",
"--runInBand",
"--group=e2e",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/vitest",
"-c",
"vitest.config.e2e.js",
"-t",
"${input:testNamePattern}"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}, {
"name": "geoprocessing scripts- debug tests",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/geoprocessing",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/packages/geoprocessing/node_modules/.bin/jest",
"--projects",
"scripts"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}, {
"name": "template-ocean-eez - debug tests",
"type": "node",
"request": "launch",
Expand All @@ -125,8 +124,8 @@
"request": "launch",
"name": "translation - debug importTerms",
"runtimeArgs": [
"-r",
"ts-node/register",
"--import",
"tsx",
],
"args": [
"${workspaceRoot}/packages/geoprocessing/src/i18n/bin/importTerms.ts"
Expand All @@ -136,8 +135,8 @@
"request": "launch",
"name": "translation - debug publishTerms",
"runtimeArgs": [
"-r",
"ts-node/register",
"--import",
"tsx",
],
"args": [
"${workspaceRoot}/packages/geoprocessing/src/i18n/bin/publishTerms.ts"
Expand All @@ -162,8 +161,8 @@
"request": "launch",
"name": "run any ts-node script",
"runtimeArgs": [
"-r",
"ts-node/register/transpile-only",
"--import",
"tsx",
],
"args": [
"${workspaceRoot}/packages/geoprocessing/${input:scriptPath}"
Expand All @@ -180,7 +179,7 @@
{
"type": "promptString",
"id": "testNamePattern",
"description": "jest -t 'regex pattern to select tests'",
"description": "vitest -t 'regex pattern to select tests'",
"default": "name of my test"
},
{
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"files.exclude": {},
"git.ignoreLimitWarning": true,
"jest.rootPath": "packages/geoprocessing",
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#004b99",
"activityBar.activeBorder": "#ff007d",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "7.0.0"
"version": "6.1.2"
}
Loading

0 comments on commit 00362ec

Please sign in to comment.