Convert pure tests to Jest

This converts all pure tests to Jest. This was done by first running
`npx jest-codemods` with the Mocha transformation, then manually fixing
any places where it hadn't automatically converted the correct thing
or had missed things (mostly Sinon).

This also sets up VSCode correctly for running Jest.
This commit is contained in:
Koen Vlaswinkel
2022-11-22 10:37:51 +01:00
parent 03f1547160
commit 0974700557
31 changed files with 625 additions and 505 deletions

View File

@@ -5,7 +5,8 @@
"recommendations": [
"amodio.tsl-problem-matcher",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"Orta.vscode-jest",
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []

24
.vscode/launch.json vendored
View File

@@ -29,24 +29,16 @@
"name": "Launch Unit Tests (vscode-codeql)",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/extensions/ql-vscode/node_modules/mocha/bin/_mocha",
"program": "${workspaceFolder}/extensions/ql-vscode/node_modules/jest/bin/jest.js",
"showAsyncStacks": true,
"cwd": "${workspaceFolder}/extensions/ql-vscode",
"runtimeArgs": [
"--inspect=9229"
],
"env": {
"LANG": "en-US"
"LANG": "en-US",
"TZ": "UTC"
},
"args": [
"--exit",
"-u",
"bdd",
"--colors",
"--diff",
"--config",
".mocharc.json",
"test/pure-tests/**/*.ts"
"--projects",
"test"
],
"stopOnEntry": false,
"sourceMaps": true,
@@ -60,6 +52,10 @@
"program": "${workspaceFolder}/extensions/ql-vscode/node_modules/jest/bin/jest.js",
"showAsyncStacks": true,
"cwd": "${workspaceFolder}/extensions/ql-vscode",
"args": [
"--projects",
"src/view"
],
"stopOnEntry": false,
"sourceMaps": true,
"console": "integratedTerminal",
@@ -117,7 +113,7 @@
"--disable-extension",
"github.copilot",
"${workspaceRoot}/extensions/ql-vscode/src/vscode-tests/cli-integration/data",
// Uncomment the last line and modify the path to a checked out
// Uncomment the last line and modify the path to a checked out
// instance of the codeql repository so the libraries are
// available in the workspace for the tests.
// "${workspaceRoot}/../codeql"

View File

@@ -37,6 +37,11 @@
"javascript.preferences.quoteStyle": "single",
"editor.wordWrapColumn": 100,
"jest.rootPath": "./extensions/ql-vscode",
"jest.autoRun": "watch",
"jest.nodeEnv": {
"LANG": "en-US",
"TZ": "UTC"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,