Skip to content

Commit

Permalink
chore: Update node to 16.4.2, vscode engine to 1.75.1, switch to @swc…
Browse files Browse the repository at this point in the history
…/jest, also fix tests
  • Loading branch information
svsool committed Feb 19, 2023
1 parent 525e777 commit 6bbe6e1
Show file tree
Hide file tree
Showing 7 changed files with 625 additions and 517 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.17.0
16.14.2
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.14.2
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"url": "https://github.com/svsool/memo/issues"
},
"engines": {
"vscode": "^1.69.0"
"vscode": "^1.75.1"
},
"categories": [
"Other"
Expand Down Expand Up @@ -263,10 +263,12 @@
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@swc/core": "^1.3.35",
"@swc/jest": "^0.2.24",
"@types/del": "^4.0.0",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^7.2.0",
"@types/jest": "^28.1.6",
"@types/jest": "^29.4.0",
"@types/lodash.debounce": "^4.0.7",
"@types/lodash.groupby": "^4.6.7",
"@types/lodash.range": "^3.2.7",
Expand All @@ -278,6 +280,7 @@
"@types/vscode": "^1.69.0",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"@vscode/test-electron": "^2.2.3",
"cross-env": "^7.0.3",
"del": "^6.0.0",
"del-cli": "^5.0.0",
Expand All @@ -289,20 +292,18 @@
"eslint-plugin-unicorn": "^40.1.0",
"glob": "^8.0.3",
"husky": "^8.0.1",
"jest": "28.1.3",
"jest-environment-node": "^28.1.3",
"jest-extended": "^3.0.1",
"jest": "29.4.3",
"jest-environment-node": "^29.4.3",
"jest-extended": "^3.2.4",
"lint-staged": "^13.0.3",
"mkdirp": "^1.0.4",
"ovsx": "^0.5.1",
"prettier": "^2.7.1",
"standard-version": "^9.5.0",
"terser-webpack-plugin": "^5.3.3",
"ts-jest": "^28.0.7",
"ts-loader": "^9.3.1",
"ts-loader": "^9.4.2",
"typescript": "^4.7.4",
"vsce": "^2.10.0",
"vscode-test": "^1.6.1",
"wait-for-expect": "^3.0.2",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
Expand Down
2 changes: 1 addition & 1 deletion src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import { runTests } from 'vscode-test';
import { runTests } from '@vscode/test-electron';

process.env.FORCE_COLOR = '1';

Expand Down
30 changes: 24 additions & 6 deletions src/test/testRunner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { runCLI } from '@jest/core';
import { AggregatedResult } from '@jest/test-result';
import util from 'util';
import path from 'path';

const getFailureMessages = (results: AggregatedResult): string[] | undefined => {
Expand All @@ -13,7 +14,27 @@ const getFailureMessages = (results: AggregatedResult): string[] | undefined =>

const rootDir = path.resolve(__dirname, '../..');

// vscode uses special mechanism to require node modules which interferes with jest-runtime and mocks functionality
// see https://bitly.com/ and https://bit.ly/3EmrV7c
const fixVscodeRuntime = () => {
const globalTyped = global as unknown as { _VSCODE_NODE_MODULES: typeof Proxy };

if (globalTyped._VSCODE_NODE_MODULES && util.types.isProxy(globalTyped._VSCODE_NODE_MODULES)) {
globalTyped._VSCODE_NODE_MODULES = new Proxy(globalTyped._VSCODE_NODE_MODULES, {
get(target, prop, receiver) {
if (prop === '_isMockFunction') {
return false;
}

return Reflect.get(target, prop, receiver);
},
});
}
};

export function run(): Promise<void> {
fixVscodeRuntime();

process.stderr.write = (buffer: string) => {
// ideally console.error should be used, but not possible due to stack overflow and how console methods are patched in vscode, see http://bit.ly/3vilufz
// using original stdout/stderr not possible either, see this issue https://github.com/microsoft/vscode/issues/74173
Expand All @@ -33,17 +54,14 @@ export function run(): Promise<void> {
roots: ['<rootDir>/src'],
verbose: true,
colors: true,
transform: JSON.stringify({ '^.+\\.ts$': 'ts-jest' }),
transform: JSON.stringify({
'\\.ts$': ['@swc/jest'],
}),
runInBand: true,
testRegex: process.env.JEST_TEST_REGEX || '\\.(test|spec)\\.ts$',
testEnvironment: '<rootDir>/src/test/env/VsCodeEnvironment.js',
setupFiles: ['<rootDir>/src/test/config/jestSetup.ts'],
setupFilesAfterEnv: ['jest-extended/all'],
globals: JSON.stringify({
'ts-jest': {
tsconfig: path.resolve(rootDir, './tsconfig.json'),
},
}),
ci: process.env.JEST_CI === 'true',
testTimeout: 30000,
watch: process.env.JEST_WATCH === 'true',
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"sourceMap": true,
"rootDir": "src",
"lib": ["es2019"],
"types": ["jest-extended"],
"types": ["jest-extended", "jest"],
"skipLibCheck": true,
"strict": true,
"noImplicitReturns": true,
Expand Down
Loading

0 comments on commit 6bbe6e1

Please sign in to comment.