From 2173021a2d52573180446f6ad9f059324baad1a3 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Mon, 3 Aug 2026 14:25:32 -0700 Subject: [PATCH 1/2] Prepare tooling for repository-wide ESM Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: fe7d6411-cf1e-4cc8-97a8-8561d9404205 (cherry picked from commit fd7f51ce8210568a57590a93cbb9ed832af77517) --- .vscode/launch.json | 20 +- .vscodeignore | 2 +- baseJestConfig.mjs | 31 +++ baseJestConfig.ts | 15 -- esbuild.js => esbuild.mjs | 12 +- eslint.config.mjs | 2 +- jest.config.ts => jest.config.mjs | 23 +- package-lock.json | 253 +++++++++++++++--- package.json | 62 ++--- tasks/tests/omnisharptestTasks.ts | 4 +- tasks/tests/testHelpers.ts | 2 +- tasks/tests/testTasks.ts | 13 +- test/jestProjectNames.d.mts | 16 ++ test/jestProjectNames.mjs | 16 ++ .../{jest.config.ts => jest.config.mjs} | 11 +- test/lsptoolshost/integrationTests/index.ts | 4 +- .../{jest.config.ts => jest.config.mjs} | 11 +- .../{jest.config.ts => jest.config.mjs} | 11 +- .../omnisharpIntegrationTests/index.ts | 4 +- .../jest.config.mjs} | 11 +- .../{jest.config.ts => jest.config.mjs} | 11 +- test/razor/razorIntegrationTests/index.ts | 4 +- .../razorIntegrationTests/jest.config.mjs} | 11 +- .../{jest.config.ts => jest.config.mjs} | 11 +- test/runIntegrationTests.ts | 2 +- .../tasks/{jest.config.ts => jest.config.mjs} | 11 +- .../integrationTests/index.ts | 4 +- .../integrationTests/jest.config.mjs} | 11 +- tsconfig.json | 2 - 29 files changed, 393 insertions(+), 197 deletions(-) create mode 100644 baseJestConfig.mjs delete mode 100644 baseJestConfig.ts rename esbuild.js => esbuild.mjs (94%) rename jest.config.ts => jest.config.mjs (83%) create mode 100644 test/jestProjectNames.d.mts create mode 100644 test/jestProjectNames.mjs rename test/lsptoolshost/artifactTests/{jest.config.ts => jest.config.mjs} (75%) rename test/lsptoolshost/integrationTests/{jest.config.ts => jest.config.mjs} (71%) rename test/lsptoolshost/unitTests/{jest.config.ts => jest.config.mjs} (82%) rename test/{razor/razorIntegrationTests/jest.config.ts => omnisharp/omnisharpIntegrationTests/jest.config.mjs} (71%) rename test/omnisharp/omnisharpUnitTests/{jest.config.ts => jest.config.mjs} (80%) rename test/{untrustedWorkspace/integrationTests/jest.config.ts => razor/razorIntegrationTests/jest.config.mjs} (71%) rename test/razor/razorTests/{jest.config.ts => jest.config.mjs} (77%) rename test/tasks/{jest.config.ts => jest.config.mjs} (71%) rename test/{omnisharp/omnisharpIntegrationTests/jest.config.ts => untrustedWorkspace/integrationTests/jest.config.mjs} (71%) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6f97b6ac3f..4bd7e13161 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -181,8 +181,8 @@ "request": "launch", "name": "Debug task", "preLaunchTask": "build", - "program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js", - "args": ["tasks/${input:taskScript}"], + "runtimeArgs": ["--import", "tsx"], + "program": "${workspaceFolder}/tasks/${input:taskScript}", "cwd": "${workspaceFolder}" }, { @@ -190,8 +190,8 @@ "request": "launch", "name": "Update OmniSharp package dependencies", "preLaunchTask": "build", - "program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js", - "args": ["tasks/debugger/updatePackageDependencies.ts"], + "runtimeArgs": ["--import", "tsx"], + "program": "${workspaceFolder}/tasks/debugger/updatePackageDependencies.ts", "env": { "NEW_DEPS_ID": "OmniSharp", "NEW_DEPS_URLS": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-linux-x64.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-linux-x86.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-linux-arm64.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-osx.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-win-x64.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-win-arm64.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-linux-musl-x64-net6.0.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-linux-musl-arm64-net6.0.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-linux-x64-net6.0.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-linux-arm64-net6.0.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-osx-x64-net6.0.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-osx-arm64-net6.0.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-win-x64-net6.0.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.14/omnisharp-win-arm64-net6.0.zip", @@ -205,8 +205,8 @@ "request": "launch", "name": "Update razor telemetry package dependencies", "preLaunchTask": "build", - "program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js", - "args": ["tasks/debugger/updatePackageDependencies.ts"], + "runtimeArgs": ["--import", "tsx"], + "program": "${workspaceFolder}/tasks/debugger/updatePackageDependencies.ts", "env": { "NEW_DEPS_URLS": "https://download.visualstudio.microsoft.com/download/pr/534f8426-a4f4-4b2d-b3ba-c4e16a38c48c/704e369c5905f9ece819ebce77fb78d8/devkittelemetry-linux-arm64-7.0.0-preview.24178.4.zip,https://download.visualstudio.microsoft.com/download/pr/534f8426-a4f4-4b2d-b3ba-c4e16a38c48c/4049a66147717a53860bbc969bf32faa/devkittelemetry-linux-musl-arm64-7.0.0-preview.24178.4.zip,https://download.visualstudio.microsoft.com/download/pr/534f8426-a4f4-4b2d-b3ba-c4e16a38c48c/c75e84ff813be5c9833d96dc2066a364/devkittelemetry-linux-musl-x64-7.0.0-preview.24178.4.zip,https://download.visualstudio.microsoft.com/download/pr/534f8426-a4f4-4b2d-b3ba-c4e16a38c48c/f58cf629939f0df77d142be881f9e233/devkittelemetry-linux-x64-7.0.0-preview.24178.4.zip,https://download.visualstudio.microsoft.com/download/pr/534f8426-a4f4-4b2d-b3ba-c4e16a38c48c/1c912419ea45c8d95cfa28a8a04640dc/devkittelemetry-osx-arm64-7.0.0-preview.24178.4.zip,https://download.visualstudio.microsoft.com/download/pr/534f8426-a4f4-4b2d-b3ba-c4e16a38c48c/36545ba0998f1fc380e877e38b2f35f1/devkittelemetry-osx-x64-7.0.0-preview.24178.4.zip,https://download.visualstudio.microsoft.com/download/pr/534f8426-a4f4-4b2d-b3ba-c4e16a38c48c/0a32698e8ba1ab93489d79f34f8ae8d0/devkittelemetry-platformagnostic-7.0.0-preview.24178.4.zip,https://download.visualstudio.microsoft.com/download/pr/534f8426-a4f4-4b2d-b3ba-c4e16a38c48c/4f16ff826fedd33ad80d265c5409588b/devkittelemetry-win-arm64-7.0.0-preview.24178.4.zip,https://download.visualstudio.microsoft.com/download/pr/534f8426-a4f4-4b2d-b3ba-c4e16a38c48c/5a98d8f4e481dbb7ae3cdb3695b75c46/devkittelemetry-win-x64-7.0.0-preview.24178.4.zip", "NEW_DEPS_VERSION": "7.0.0-preview.24178.4", @@ -219,8 +219,8 @@ "request": "launch", "name": "Generate debugger options schema", "preLaunchTask": "build", - "program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js", - "args": ["tasks/debugger/generateOptionsSchema.ts"], + "runtimeArgs": ["--import", "tsx"], + "program": "${workspaceFolder}/tasks/debugger/generateOptionsSchema.ts", "cwd": "${workspaceFolder}" }, { @@ -228,8 +228,8 @@ "request": "launch", "name": "Razor Cohost integration tests", "preLaunchTask": "build", - "program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js", - "args": ["tasks/tests/testIntegrationRazorCohost.ts"], + "runtimeArgs": ["--import", "tsx"], + "program": "${workspaceFolder}/tasks/tests/testIntegrationRazorCohost.ts", "cwd": "${workspaceFolder}" } ], diff --git a/.vscodeignore b/.vscodeignore index b1a2737ee7..57e8717e36 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -49,7 +49,7 @@ package-lock.json tsconfig.json version.json wallaby.js -esbuild.js +esbuild.mjs !src/razor/language-configuration.json !src/razor/syntaxes/* diff --git a/baseJestConfig.mjs b/baseJestConfig.mjs new file mode 100644 index 0000000000..0d444b10a3 --- /dev/null +++ b/baseJestConfig.mjs @@ -0,0 +1,31 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +import { readFileSync } from 'node:fs'; +import { createDefaultEsmPreset, createDefaultPreset } from 'ts-jest'; + +const packageJson = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')); +// The override lets tooling validate the ESM transform before the repository package type changes. +const useESM = packageJson.type === 'module' || process.env.JEST_USE_ESM === 'true'; +const tsJestPreset = useESM + ? createDefaultEsmPreset({ tsconfig: './tsconfig.json' }) + : createDefaultPreset({ tsconfig: './tsconfig.json' }); + +/** + * Defines a base project config that we can re-use across the project specific jest configs. + * We do this because jest generally does not inherit project configuration settings. + */ +/** @type {import('jest').Config} */ +export const baseProjectConfig = { + ...tsJestPreset, + testEnvironment: 'node', + transformIgnorePatterns: ['/dist/.+\\.js'], + ...(useESM + ? { + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, + } + : {}), +}; diff --git a/baseJestConfig.ts b/baseJestConfig.ts deleted file mode 100644 index 5b7935c769..0000000000 --- a/baseJestConfig.ts +++ /dev/null @@ -1,15 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; - -/** - * Defines a base project config that we can re-use across the project specific jest configs. - * We do this because jest generally does not inherit project configuration settings. - */ -export const baseProjectConfig: Config = { - preset: 'ts-jest', - testEnvironment: 'node', - transformIgnorePatterns: ['/dist/.+\\.js'], -}; diff --git a/esbuild.js b/esbuild.mjs similarity index 94% rename from esbuild.js rename to esbuild.mjs index f34c5912ac..dabb1ab213 100644 --- a/esbuild.js +++ b/esbuild.mjs @@ -1,5 +1,5 @@ -const esbuild = require("esbuild"); -const fs = require('fs/promises'); +import esbuild from 'esbuild'; +import fs from 'node:fs/promises'; const production = process.argv.includes('--production'); const watch = process.argv.includes('--watch'); @@ -44,9 +44,7 @@ const umdEsmLoaderPlugin = { async function main() { const ctx = await esbuild.context({ - entryPoints: [ - 'src/main.ts' - ], + entryPoints: ['src/main.ts'], bundle: true, format: 'esm', banner: { @@ -81,7 +79,7 @@ async function main() { } } -main().catch(e => { +main().catch((e) => { console.error(e); process.exit(1); -}); \ No newline at end of file +}); diff --git a/eslint.config.mjs b/eslint.config.mjs index d5c3dfd9f1..7dcb90326f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -23,7 +23,7 @@ const compatibleHeaderPlugin = fixupPluginRules({ export default defineConfig([ { - ignores: ['out/**', 'dist/**', 'wallaby.js', 'eslint.config.mjs', 'esbuild.js', '**/*.d.ts'], + ignores: ['out/**', 'dist/**', 'wallaby.js', 'eslint.config.mjs', 'esbuild.mjs', '**/*.d.ts'], }, { files: ['**/*.ts'], diff --git a/jest.config.ts b/jest.config.mjs similarity index 83% rename from jest.config.ts rename to jest.config.mjs index 54ca228dea..a27f4be457 100644 --- a/jest.config.ts +++ b/jest.config.mjs @@ -2,19 +2,18 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; - -const config: Config = { +/** @type {import('jest').Config} */ +const config = { projects: [ - '/test/lsptoolshost/artifactTests/jest.config.ts', - '/test/lsptoolshost/integrationTests/jest.config.ts', - '/test/lsptoolshost/unitTests/jest.config.ts', - '/test/omnisharp/omnisharpIntegrationTests/jest.config.ts', - '/test/omnisharp/omnisharpUnitTests/jest.config.ts', - '/test/razor/razorIntegrationTests/jest.config.ts', - '/test/razor/razorTests/jest.config.ts', - '/test/untrustedWorkspace/integrationTests/jest.config.ts', - '/test/tasks/jest.config.ts', + '/test/lsptoolshost/artifactTests/jest.config.mjs', + '/test/lsptoolshost/integrationTests/jest.config.mjs', + '/test/lsptoolshost/unitTests/jest.config.mjs', + '/test/omnisharp/omnisharpIntegrationTests/jest.config.mjs', + '/test/omnisharp/omnisharpUnitTests/jest.config.mjs', + '/test/razor/razorIntegrationTests/jest.config.mjs', + '/test/razor/razorTests/jest.config.mjs', + '/test/untrustedWorkspace/integrationTests/jest.config.mjs', + '/test/tasks/jest.config.mjs', ], // Reporters are a global jest configuration property and cannot be set in the project jest config. // This configuration will create a 'junit.xml' file in the output directory, no matter which test project is running. diff --git a/package-lock.json b/package-lock.json index 045c1c0871..a29c0f40d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -58,8 +58,8 @@ "nerdbank-gitversioning": "^3.6.79-alpha", "prettier": "3.9.6", "tmp": "0.2.7", - "ts-jest": "^29.1.1", - "ts-node": "9.1.1", + "ts-jest": "^29.4.1", + "tsx": "^4.20.6", "typescript": "5.6.2", "typescript-eslint": "^8.65.0", "vscode-oniguruma": "^1.6.1", @@ -4187,7 +4187,9 @@ "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/arg/-/arg-4.1.3.tgz", "integrity": "sha1-Jp/HrVuOQstjyJbVZmAXJhwUQIk=", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/argparse": { "version": "1.0.10", @@ -5086,7 +5088,9 @@ "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/create-require/-/create-require-1.1.1.tgz", "integrity": "sha1-wdfo8eX2z8n/ZfnNNS03NIdWwzM=", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/cross-spawn": { "version": "7.0.6", @@ -5335,6 +5339,8 @@ "integrity": "sha1-em2/2jJfJfB1F+m1GPiXwIMy4H0=", "dev": true, "license": "BSD-3-Clause", + "optional": true, + "peer": true, "engines": { "node": ">=0.3.1" } @@ -6341,11 +6347,11 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha1-ysZAd4XQNnWipeGlMFxpezR9kNY=", "dev": true, - "hasInstallScript": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -6606,6 +6612,28 @@ "integrity": "sha1-QYPk6L8Iu24Fu7L30uDI9xLKQOM=", "license": "ISC" }, + "node_modules/handlebars": { + "version": "4.7.9", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/handlebars/-/handlebars-4.7.9.tgz", + "integrity": "sha1-bxOQgqtY3E5aDlHv59ta6JDVag8=", + "dev": true, + "license": "MIT", + "dependencies": { + "minimist": "^1.2.5", + "neo-async": "^2.6.2", + "source-map": "^0.6.1", + "wordwrap": "^1.0.0" + }, + "bin": { + "handlebars": "bin/handlebars" + }, + "engines": { + "node": ">=0.4.7" + }, + "optionalDependencies": { + "uglify-js": "^3.1.4" + } + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/has/-/has-1.0.3.tgz", @@ -8668,8 +8696,7 @@ "version": "1.2.6", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/minimist/-/minimist-1.2.6.tgz", "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", - "dev": true, - "optional": true + "dev": true }, "node_modules/minipass": { "version": "7.1.2", @@ -8775,6 +8802,13 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/neo-async": { + "version": "2.6.2", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha1-tKr7k+OustgXTKU88WOrfXMIMF8=", + "dev": true, + "license": "MIT" + }, "node_modules/nerdbank-gitversioning": { "version": "3.6.79-alpha", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/nerdbank-gitversioning/-/nerdbank-gitversioning-3.6.79-alpha.tgz", @@ -10519,6 +10553,8 @@ "integrity": "sha1-BP58f54e0tZiIzwoyys1ufY/bk8=", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -11078,37 +11114,44 @@ } }, "node_modules/ts-jest": { - "version": "29.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ts-jest/-/ts-jest-29.1.1.tgz", - "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "version": "29.4.12", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ts-jest/-/ts-jest-29.4.12.tgz", + "integrity": "sha1-w0zZHwLTZOkobSwBaEMxX9Dv/3Y=", "dev": true, + "license": "MIT", "dependencies": { - "bs-logger": "0.x", - "fast-json-stable-stringify": "2.x", - "jest-util": "^29.0.0", + "bs-logger": "^0.2.6", + "fast-json-stable-stringify": "^2.1.0", + "handlebars": "^4.7.9", "json5": "^2.2.3", - "lodash.memoize": "4.x", - "make-error": "1.x", - "semver": "^7.5.3", - "yargs-parser": "^21.0.1" + "lodash.memoize": "^4.1.2", + "make-error": "^1.3.6", + "semver": "^7.8.5", + "type-fest": "^4.41.0", + "yargs-parser": "^21.1.1" }, "bin": { "ts-jest": "cli.js" }, "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" }, "peerDependencies": { "@babel/core": ">=7.0.0-beta.0 <8", - "@jest/types": "^29.0.0", - "babel-jest": "^29.0.0", - "jest": "^29.0.0", - "typescript": ">=4.3 <6" + "@jest/transform": "^29.0.0 || ^30.0.0", + "@jest/types": "^29.0.0 || ^30.0.0", + "babel-jest": "^29.0.0 || ^30.0.0", + "jest": "^29.0.0 || ^30.0.0", + "jest-util": "^29.0.0 || ^30.0.0", + "typescript": ">=4.3 <7" }, "peerDependenciesMeta": { "@babel/core": { "optional": true }, + "@jest/transform": { + "optional": true + }, "@jest/types": { "optional": true }, @@ -11117,15 +11160,33 @@ }, "esbuild": { "optional": true + }, + "jest-util": { + "optional": true } } }, + "node_modules/ts-jest/node_modules/semver": { + "version": "7.8.5", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/semver/-/semver-7.8.5.tgz", + "integrity": "sha1-ObZGA33VDBT7RR5+TKxY7YuGP2k=", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/ts-node": { "version": "9.1.1", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ts-node/-/ts-node-9.1.1.tgz", "integrity": "sha1-UamkUKPpWUAb2l8ASnLVS5NtN20=", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "arg": "^4.1.0", "create-require": "^1.1.0", @@ -11152,6 +11213,25 @@ "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/tslib/-/tslib-1.13.0.tgz", "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" }, + "node_modules/tsx": { + "version": "4.23.1", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/tsx/-/tsx-4.23.1.tgz", + "integrity": "sha1-FwPaAC7kQyuaBTkXQx+RRi/KI1s=", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.28.0" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, "node_modules/tunnel": { "version": "0.0.6", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/tunnel/-/tunnel-0.0.6.tgz", @@ -11280,6 +11360,20 @@ "dev": true, "license": "MIT" }, + "node_modules/uglify-js": { + "version": "3.19.3", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/uglify-js/-/uglify-js-3.19.3.tgz", + "integrity": "sha1-gjFem7xvKyWIiFis0f/4RBA1t38=", + "dev": true, + "license": "BSD-2-Clause", + "optional": true, + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/uid-safe": { "version": "2.1.5", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/uid-safe/-/uid-safe-2.1.5.tgz", @@ -11629,6 +11723,13 @@ "node": ">=0.10.0" } }, + "node_modules/wordwrap": { + "version": "1.0.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true, + "license": "MIT" + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -11795,6 +11896,8 @@ "integrity": "sha1-HodAGgnXZ8HV6rJqbkwYUYLS61A=", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">=6" } @@ -14757,7 +14860,9 @@ "version": "4.1.3", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/arg/-/arg-4.1.3.tgz", "integrity": "sha1-Jp/HrVuOQstjyJbVZmAXJhwUQIk=", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "argparse": { "version": "1.0.10", @@ -15410,7 +15515,9 @@ "version": "1.1.1", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/create-require/-/create-require-1.1.1.tgz", "integrity": "sha1-wdfo8eX2z8n/ZfnNNS03NIdWwzM=", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "cross-spawn": { "version": "7.0.6", @@ -15567,7 +15674,9 @@ "version": "4.0.4", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/diff/-/diff-4.0.4.tgz", "integrity": "sha1-em2/2jJfJfB1F+m1GPiXwIMy4H0=", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "diff-sequences": { "version": "29.6.3", @@ -16257,9 +16366,9 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { - "version": "2.3.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha1-ysZAd4XQNnWipeGlMFxpezR9kNY=", "dev": true, "optional": true }, @@ -16421,6 +16530,19 @@ "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha1-QYPk6L8Iu24Fu7L30uDI9xLKQOM=" }, + "handlebars": { + "version": "4.7.9", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/handlebars/-/handlebars-4.7.9.tgz", + "integrity": "sha1-bxOQgqtY3E5aDlHv59ta6JDVag8=", + "dev": true, + "requires": { + "minimist": "^1.2.5", + "neo-async": "^2.6.2", + "source-map": "^0.6.1", + "uglify-js": "^3.1.4", + "wordwrap": "^1.0.0" + } + }, "has": { "version": "1.0.3", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/has/-/has-1.0.3.tgz", @@ -17920,8 +18042,7 @@ "version": "1.2.6", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/minimist/-/minimist-1.2.6.tgz", "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "7.1.2", @@ -18003,6 +18124,12 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "neo-async": { + "version": "2.6.2", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha1-tKr7k+OustgXTKU88WOrfXMIMF8=", + "dev": true + }, "nerdbank-gitversioning": { "version": "3.6.79-alpha", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/nerdbank-gitversioning/-/nerdbank-gitversioning-3.6.79-alpha.tgz", @@ -19191,6 +19318,8 @@ "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/source-map-support/-/source-map-support-0.5.21.tgz", "integrity": "sha1-BP58f54e0tZiIzwoyys1ufY/bk8=", "dev": true, + "optional": true, + "peer": true, "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -19588,19 +19717,28 @@ "requires": {} }, "ts-jest": { - "version": "29.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ts-jest/-/ts-jest-29.1.1.tgz", - "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "version": "29.4.12", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ts-jest/-/ts-jest-29.4.12.tgz", + "integrity": "sha1-w0zZHwLTZOkobSwBaEMxX9Dv/3Y=", "dev": true, "requires": { - "bs-logger": "0.x", - "fast-json-stable-stringify": "2.x", - "jest-util": "^29.0.0", + "bs-logger": "^0.2.6", + "fast-json-stable-stringify": "^2.1.0", + "handlebars": "^4.7.9", "json5": "^2.2.3", - "lodash.memoize": "4.x", - "make-error": "1.x", - "semver": "^7.5.3", - "yargs-parser": "^21.0.1" + "lodash.memoize": "^4.1.2", + "make-error": "^1.3.6", + "semver": "^7.8.5", + "type-fest": "^4.41.0", + "yargs-parser": "^21.1.1" + }, + "dependencies": { + "semver": { + "version": "7.8.5", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/semver/-/semver-7.8.5.tgz", + "integrity": "sha1-ObZGA33VDBT7RR5+TKxY7YuGP2k=", + "dev": true + } } }, "ts-node": { @@ -19608,6 +19746,8 @@ "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ts-node/-/ts-node-9.1.1.tgz", "integrity": "sha1-UamkUKPpWUAb2l8ASnLVS5NtN20=", "dev": true, + "optional": true, + "peer": true, "requires": { "arg": "^4.1.0", "create-require": "^1.1.0", @@ -19622,6 +19762,16 @@ "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/tslib/-/tslib-1.13.0.tgz", "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" }, + "tsx": { + "version": "4.23.1", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/tsx/-/tsx-4.23.1.tgz", + "integrity": "sha1-FwPaAC7kQyuaBTkXQx+RRi/KI1s=", + "dev": true, + "requires": { + "esbuild": "~0.28.0", + "fsevents": "~2.3.3" + } + }, "tunnel": { "version": "0.0.6", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/tunnel/-/tunnel-0.0.6.tgz", @@ -19704,6 +19854,13 @@ "integrity": "sha1-+NP30OxMPeo1p+PI76TLi0XJ5+4=", "dev": true }, + "uglify-js": { + "version": "3.19.3", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/uglify-js/-/uglify-js-3.19.3.tgz", + "integrity": "sha1-gjFem7xvKyWIiFis0f/4RBA1t38=", + "dev": true, + "optional": true + }, "uid-safe": { "version": "2.1.5", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/uid-safe/-/uid-safe-2.1.5.tgz", @@ -19948,6 +20105,12 @@ "integrity": "sha1-0sRcbdT7zmIaZvE2y+Mor9BBCzQ=", "dev": true }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, "wrap-ansi": { "version": "7.0.0", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -20061,7 +20224,9 @@ "version": "3.1.1", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/yn/-/yn-3.1.1.tgz", "integrity": "sha1-HodAGgnXZ8HV6rJqbkwYUYLS61A=", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "yocto-queue": { "version": "0.1.0", diff --git a/package.json b/package.json index 0fc62c1471..f39ec10691 100644 --- a/package.json +++ b/package.json @@ -67,43 +67,43 @@ "compile": "tsc -p tsconfig.json && npm run lint && npm run l10nDevGenerateLocalizationBundle && npm run compile:razorTextMate", "compileDev": "tsc -p tsconfig.json && npm run lint && npm run l10nDevGenerateLocalizationBundle && npm run compile:razorTextMate", "compile:razorTextMate": "npx js-yaml src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml > src/razor/syntaxes/aspnetcorerazor.tmLanguage.json", - "createTags": "npx ts-node tasks/tags/createTags.ts", - "fixLocUrls": "npx ts-node tasks/debugger/fixLocUrls.ts", - "generateOptionsSchema": "npx ts-node tasks/debugger/generateOptionsSchema.ts", - "incrementVersion": "npx ts-node tasks/snap/incrementVersion.ts", - "installDependencies": "npx ts-node tasks/packaging/installDependencies.ts", - "installDependenciesClean": "npx ts-node tasks/packaging/installDependenciesClean.ts", - "installSignPlugin": "npx ts-node tasks/signing/installSignPlugin.ts", + "createTags": "npx tsx tasks/tags/createTags.ts", + "fixLocUrls": "npx tsx tasks/debugger/fixLocUrls.ts", + "generateOptionsSchema": "npx tsx tasks/debugger/generateOptionsSchema.ts", + "incrementVersion": "npx tsx tasks/snap/incrementVersion.ts", + "installDependencies": "npx tsx tasks/packaging/installDependencies.ts", + "installDependenciesClean": "npx tsx tasks/packaging/installDependenciesClean.ts", + "installSignPlugin": "npx tsx tasks/signing/installSignPlugin.ts", "l10nDevGenerateLocalizationBundle": "npx @vscode/l10n-dev export --outDir ./l10n ./src", "l10nDevGenerateXlf": "npx @vscode/l10n-dev generate-xlf ./package.nls.json ./l10n/bundle.l10n.json --outFile ./loc/vscode-csharp.xlf", "l10nDevImportXlf": "npx @vscode/l10n-dev import-xlf ./loc/vscode-csharp.*.xlf --outDir ./l10n && move l10n\\package.nls.*.json .", "lint": "npx eslint ./", - "omnisharptest": "npm run packageDev && npx ts-node tasks/tests/omnisharptest.ts", - "omnisharptest:integration": "npm run packageDev && npx ts-node tasks/tests/omnisharptestIntegration.ts", - "omnisharptest:unit": "npm run compileDev && npx ts-node tasks/tests/omnisharptestUnit.ts", - "package": "npm run compile && node esbuild.js --production && npm run signJs", - "packageDev": "npm run compileDev && node esbuild.js", + "omnisharptest": "npm run packageDev && npx tsx tasks/tests/omnisharptest.ts", + "omnisharptest:integration": "npm run packageDev && npx tsx tasks/tests/omnisharptestIntegration.ts", + "omnisharptest:unit": "npm run compileDev && npx tsx tasks/tests/omnisharptestUnit.ts", + "package": "npm run compile && node esbuild.mjs --production && npm run signJs", + "packageDev": "npm run compileDev && node esbuild.mjs", "prepare": "npm run installDependencies", - "profiling": "npm run package && npx ts-node tasks/profiling/profiling.ts", - "publishLocalizationContent": "npx ts-node tasks/localization/publishLocalizationContent.ts", - "publishRoslynCopilot": "npx ts-node tasks/components/publishRoslynCopilot.ts", - "signJs": "npx ts-node tasks/signing/signJs.ts", - "signVsix": "npx ts-node tasks/signing/signVsix.ts", + "profiling": "npm run package && npx tsx tasks/profiling/profiling.ts", + "publishLocalizationContent": "npx tsx tasks/localization/publishLocalizationContent.ts", + "publishRoslynCopilot": "npx tsx tasks/components/publishRoslynCopilot.ts", + "signJs": "npx tsx tasks/signing/signJs.ts", + "signVsix": "npx tsx tasks/signing/signVsix.ts", "test": "npm run test:unit && npm run test:artifacts", - "test:artifacts": "npm run compileDev && npx ts-node tasks/tests/testArtifacts.ts", + "test:artifacts": "npm run compileDev && npx tsx tasks/tests/testArtifacts.ts", "test:integration": "npm run test:integration:csharp && npm run test:integration:devkit && npm run test:integration:razor:cohost && npm run test:integration:untrusted", - "test:integration:csharp": "npm run packageDev && npx ts-node tasks/tests/testIntegrationCsharp.ts", - "test:integration:devkit": "npm run packageDev && npx ts-node tasks/tests/testIntegrationDevkit.ts", - "test:integration:razor:cohost": "npm run packageDev && npx ts-node tasks/tests/testIntegrationRazorCohost.ts", - "test:integration:untrusted": "npm run packageDev && npx ts-node tasks/tests/testIntegrationUntrusted.ts", - "test:unit": "npm run compileDev && npx ts-node tasks/tests/testUnit.ts", - "updateChangelog": "npx ts-node tasks/snap/updateChangelog.ts", - "updatePackageDependencies": "npx ts-node tasks/debugger/updatePackageDependencies.ts", - "updateRoslynVersion": "npx ts-node tasks/packaging/updateRoslynVersion.ts", - "updateVersionForStableRelease": "npx ts-node tasks/snap/updateVersionForStableRelease.ts", - "verifyVsix": "npx ts-node tasks/signing/verifyVsix.ts", + "test:integration:csharp": "npm run packageDev && npx tsx tasks/tests/testIntegrationCsharp.ts", + "test:integration:devkit": "npm run packageDev && npx tsx tasks/tests/testIntegrationDevkit.ts", + "test:integration:razor:cohost": "npm run packageDev && npx tsx tasks/tests/testIntegrationRazorCohost.ts", + "test:integration:untrusted": "npm run packageDev && npx tsx tasks/tests/testIntegrationUntrusted.ts", + "test:unit": "npm run compileDev && npx tsx tasks/tests/testUnit.ts", + "updateChangelog": "npx tsx tasks/snap/updateChangelog.ts", + "updatePackageDependencies": "npx tsx tasks/debugger/updatePackageDependencies.ts", + "updateRoslynVersion": "npx tsx tasks/packaging/updateRoslynVersion.ts", + "updateVersionForStableRelease": "npx tsx tasks/snap/updateVersionForStableRelease.ts", + "verifyVsix": "npx tsx tasks/signing/verifyVsix.ts", "vscode:prepublish": "npm run package", - "vsix:release:package": "npx ts-node tasks/packaging/vsixReleasePackage.ts" + "vsix:release:package": "npx tsx tasks/packaging/vsixReleasePackage.ts" }, "extensionDependencies": [ "ms-dotnettools.vscode-dotnet-runtime" @@ -158,8 +158,8 @@ "nerdbank-gitversioning": "^3.6.79-alpha", "prettier": "3.9.6", "tmp": "0.2.7", - "ts-jest": "^29.1.1", - "ts-node": "9.1.1", + "ts-jest": "^29.4.1", + "tsx": "^4.20.6", "typescript": "5.6.2", "typescript-eslint": "^8.65.0", "vscode-oniguruma": "^1.6.1", diff --git a/tasks/tests/omnisharptestTasks.ts b/tasks/tests/omnisharptestTasks.ts index a74e229d58..c47670eef0 100644 --- a/tasks/tests/omnisharptestTasks.ts +++ b/tasks/tests/omnisharptestTasks.ts @@ -6,12 +6,12 @@ import path from 'path'; import { codeExtensionPath, rootPath } from '../projectPaths'; import { runJestIntegrationTest, runJestTest } from './testHelpers'; -import { jestOmniSharpUnitTestProjectName } from '../../test/omnisharp/omnisharpUnitTests/jest.config'; +import { jestProjectNames } from '../../test/jestProjectNames.mjs'; const omnisharpIntegrationTestProjects = ['singleCsproj', 'slnWithCsproj', 'slnFilterWithCsproj', 'BasicRazorApp2_1']; export async function omnisharpTestUnit(): Promise { - await runJestTest(jestOmniSharpUnitTestProjectName); + await runJestTest(jestProjectNames.omnisharpUnit); } export async function omnisharpTestIntegration(skipLsp: boolean = false): Promise { diff --git a/tasks/tests/testHelpers.ts b/tasks/tests/testHelpers.ts index 5f2b00a582..2dcb9cf272 100644 --- a/tasks/tests/testHelpers.ts +++ b/tasks/tests/testHelpers.ts @@ -147,7 +147,7 @@ export function getJUnitFileName(logName: string) { export async function runJestTest(project: string) { process.env.JEST_JUNIT_OUTPUT_NAME = getJUnitFileName(project); process.env.JEST_SUITE_NAME = project; - const configPath = path.join(rootPath, 'jest.config.ts'); + const configPath = path.join(rootPath, 'jest.config.mjs'); const { results } = await jest.runCLI( { diff --git a/tasks/tests/testTasks.ts b/tasks/tests/testTasks.ts index 8bf8dd0f23..2525958b18 100644 --- a/tasks/tests/testTasks.ts +++ b/tasks/tests/testTasks.ts @@ -5,15 +5,12 @@ import path from 'path'; import { integrationTestProjects, runDevKitIntegrationTests, runIntegrationTest, runJestTest } from './testHelpers'; -import { jestArtifactTestsProjectName } from '../../test/lsptoolshost/artifactTests/jest.config'; -import { jestUnitTestProjectName } from '../../test/lsptoolshost/unitTests/jest.config'; -import { razorTestProjectName } from '../../test/razor/razorTests/jest.config'; -import { jestTasksTestProjectName } from '../../test/tasks/jest.config'; +import { jestProjectNames } from '../../test/jestProjectNames.mjs'; const razorIntegrationTestProjects = ['RazorApp']; export async function testArtifacts(): Promise { - await runJestTest(jestArtifactTestsProjectName); + await runJestTest(jestProjectNames.artifact); } export async function testIntegrationCSharp(): Promise { @@ -43,7 +40,7 @@ export async function testIntegrationUntrusted(): Promise { } export async function testUnit(): Promise { - await runJestTest(jestUnitTestProjectName); - await runJestTest(razorTestProjectName); - await runJestTest(jestTasksTestProjectName); + await runJestTest(jestProjectNames.unit); + await runJestTest(jestProjectNames.razorUnit); + await runJestTest(jestProjectNames.tasksUnit); } diff --git a/test/jestProjectNames.d.mts b/test/jestProjectNames.d.mts new file mode 100644 index 0000000000..64adc29abc --- /dev/null +++ b/test/jestProjectNames.d.mts @@ -0,0 +1,16 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +export const jestProjectNames: Readonly<{ + artifact: 'Artifact Tests'; + integration: 'Integration Tests'; + omnisharpIntegration: 'OmniSharp Integration Tests'; + omnisharpUnit: 'OmniSharp Unit Tests'; + razorIntegration: 'Razor Integration Tests'; + razorUnit: 'Razor Unit Tests'; + tasksUnit: 'Tasks Unit Tests'; + unit: 'Unit Tests'; + untrustedIntegration: 'Untrusted Integration Tests'; +}>; diff --git a/test/jestProjectNames.mjs b/test/jestProjectNames.mjs new file mode 100644 index 0000000000..8b9f32ba0b --- /dev/null +++ b/test/jestProjectNames.mjs @@ -0,0 +1,16 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +export const jestProjectNames = Object.freeze({ + artifact: 'Artifact Tests', + integration: 'Integration Tests', + omnisharpIntegration: 'OmniSharp Integration Tests', + omnisharpUnit: 'OmniSharp Unit Tests', + razorIntegration: 'Razor Integration Tests', + razorUnit: 'Razor Unit Tests', + tasksUnit: 'Tasks Unit Tests', + unit: 'Unit Tests', + untrustedIntegration: 'Untrusted Integration Tests', +}); diff --git a/test/lsptoolshost/artifactTests/jest.config.ts b/test/lsptoolshost/artifactTests/jest.config.mjs similarity index 75% rename from test/lsptoolshost/artifactTests/jest.config.ts rename to test/lsptoolshost/artifactTests/jest.config.mjs index 5135e61343..3612a32958 100644 --- a/test/lsptoolshost/artifactTests/jest.config.ts +++ b/test/lsptoolshost/artifactTests/jest.config.mjs @@ -2,17 +2,16 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; -import { baseProjectConfig } from '../../../baseJestConfig'; - -export const jestArtifactTestsProjectName = 'Artifact Tests'; +import { baseProjectConfig } from '../../../baseJestConfig.mjs'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; /** * Defines a jest project configuration for artifact tests. */ -const unitTestConfig: Config = { +/** @type {import('jest').Config} */ +const unitTestConfig = { ...baseProjectConfig, - displayName: jestArtifactTestsProjectName, + displayName: jestProjectNames.artifact, // We need to explicity ignore the out directory for modules - otherwise we'll get duplicate vscode module, // the TS version from the __mocks__ directory and the compiled js version from the out directory. modulePathIgnorePatterns: ['out'], diff --git a/test/lsptoolshost/integrationTests/index.ts b/test/lsptoolshost/integrationTests/index.ts index ac2e6a90a2..2c6aaf1426 100644 --- a/test/lsptoolshost/integrationTests/index.ts +++ b/test/lsptoolshost/integrationTests/index.ts @@ -4,10 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import { runIntegrationTests } from '../../runIntegrationTests'; -import { jestIntegrationTestProjectName } from './jest.config'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; export async function run() { process.env.RUNNING_INTEGRATION_TESTS = 'true'; - await runIntegrationTests(jestIntegrationTestProjectName); + await runIntegrationTests(jestProjectNames.integration); } diff --git a/test/lsptoolshost/integrationTests/jest.config.ts b/test/lsptoolshost/integrationTests/jest.config.mjs similarity index 71% rename from test/lsptoolshost/integrationTests/jest.config.ts rename to test/lsptoolshost/integrationTests/jest.config.mjs index 4865b32f23..1c0eb4ac11 100644 --- a/test/lsptoolshost/integrationTests/jest.config.ts +++ b/test/lsptoolshost/integrationTests/jest.config.mjs @@ -2,17 +2,16 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; -import { baseProjectConfig } from '../../../baseJestConfig'; - -export const jestIntegrationTestProjectName = 'Integration Tests'; +import { baseProjectConfig } from '../../../baseJestConfig.mjs'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; /** * Defines a project configuration for jest integration tests. */ -const integrationTestConfig: Config = { +/** @type {import('jest').Config} */ +const integrationTestConfig = { ...baseProjectConfig, - displayName: jestIntegrationTestProjectName, + displayName: jestProjectNames.integration, roots: [''], testEnvironment: '/../../vsCodeEnvironment.ts', setupFilesAfterEnv: ['/../../vsCodeFramework.ts'], diff --git a/test/lsptoolshost/unitTests/jest.config.ts b/test/lsptoolshost/unitTests/jest.config.mjs similarity index 82% rename from test/lsptoolshost/unitTests/jest.config.ts rename to test/lsptoolshost/unitTests/jest.config.mjs index 01db2c61b5..5d7c8a0065 100644 --- a/test/lsptoolshost/unitTests/jest.config.ts +++ b/test/lsptoolshost/unitTests/jest.config.mjs @@ -2,17 +2,16 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; -import { baseProjectConfig } from '../../../baseJestConfig'; - -export const jestUnitTestProjectName = 'Unit Tests'; +import { baseProjectConfig } from '../../../baseJestConfig.mjs'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; /** * Defines a jest project configuration for unit tests. */ -const unitTestConfig: Config = { +/** @type {import('jest').Config} */ +const unitTestConfig = { ...baseProjectConfig, - displayName: jestUnitTestProjectName, + displayName: jestProjectNames.unit, // We need to explicity ignore the out directory for modules - otherwise we'll get duplicate vscode module, // the TS version from the __mocks__ directory and the compiled js version from the out directory. modulePathIgnorePatterns: ['out'], diff --git a/test/omnisharp/omnisharpIntegrationTests/index.ts b/test/omnisharp/omnisharpIntegrationTests/index.ts index ac2e6a90a2..0abf1e29a0 100644 --- a/test/omnisharp/omnisharpIntegrationTests/index.ts +++ b/test/omnisharp/omnisharpIntegrationTests/index.ts @@ -4,10 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import { runIntegrationTests } from '../../runIntegrationTests'; -import { jestIntegrationTestProjectName } from './jest.config'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; export async function run() { process.env.RUNNING_INTEGRATION_TESTS = 'true'; - await runIntegrationTests(jestIntegrationTestProjectName); + await runIntegrationTests(jestProjectNames.omnisharpIntegration); } diff --git a/test/razor/razorIntegrationTests/jest.config.ts b/test/omnisharp/omnisharpIntegrationTests/jest.config.mjs similarity index 71% rename from test/razor/razorIntegrationTests/jest.config.ts rename to test/omnisharp/omnisharpIntegrationTests/jest.config.mjs index fd5bec1dc4..bcfc9b3725 100644 --- a/test/razor/razorIntegrationTests/jest.config.ts +++ b/test/omnisharp/omnisharpIntegrationTests/jest.config.mjs @@ -2,17 +2,16 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; -import { baseProjectConfig } from '../../../baseJestConfig'; - -export const jestIntegrationTestProjectName = 'Razor Integration Tests'; +import { baseProjectConfig } from '../../../baseJestConfig.mjs'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; /** * Defines a project configuration for jest integration tests. */ -const integrationTestConfig: Config = { +/** @type {import('jest').Config} */ +const integrationTestConfig = { ...baseProjectConfig, - displayName: jestIntegrationTestProjectName, + displayName: jestProjectNames.omnisharpIntegration, roots: [''], testEnvironment: '/../../vsCodeEnvironment.ts', setupFilesAfterEnv: ['/../../vsCodeFramework.ts'], diff --git a/test/omnisharp/omnisharpUnitTests/jest.config.ts b/test/omnisharp/omnisharpUnitTests/jest.config.mjs similarity index 80% rename from test/omnisharp/omnisharpUnitTests/jest.config.ts rename to test/omnisharp/omnisharpUnitTests/jest.config.mjs index 842dc5e763..f25bda44b6 100644 --- a/test/omnisharp/omnisharpUnitTests/jest.config.ts +++ b/test/omnisharp/omnisharpUnitTests/jest.config.mjs @@ -2,17 +2,16 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; -import { baseProjectConfig } from '../../../baseJestConfig'; - -export const jestOmniSharpUnitTestProjectName = 'OmniSharp Unit Tests'; +import { baseProjectConfig } from '../../../baseJestConfig.mjs'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; /** * Defines a jest project configuration for O# jest tests. */ -const omnisharpConfig: Config = { +/** @type {import('jest').Config} */ +const omnisharpConfig = { ...baseProjectConfig, - displayName: jestOmniSharpUnitTestProjectName, + displayName: jestProjectNames.omnisharpUnit, // We need to explicity ignore the out directory for modules - otherwise we'll get duplicate vscode module, // the TS version from the __mocks__ directory and the compiled js version from the out directory. modulePathIgnorePatterns: ['out'], diff --git a/test/razor/razorIntegrationTests/index.ts b/test/razor/razorIntegrationTests/index.ts index ac2e6a90a2..d09e2d3853 100644 --- a/test/razor/razorIntegrationTests/index.ts +++ b/test/razor/razorIntegrationTests/index.ts @@ -4,10 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import { runIntegrationTests } from '../../runIntegrationTests'; -import { jestIntegrationTestProjectName } from './jest.config'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; export async function run() { process.env.RUNNING_INTEGRATION_TESTS = 'true'; - await runIntegrationTests(jestIntegrationTestProjectName); + await runIntegrationTests(jestProjectNames.razorIntegration); } diff --git a/test/untrustedWorkspace/integrationTests/jest.config.ts b/test/razor/razorIntegrationTests/jest.config.mjs similarity index 71% rename from test/untrustedWorkspace/integrationTests/jest.config.ts rename to test/razor/razorIntegrationTests/jest.config.mjs index 80b28bf20d..4441b27616 100644 --- a/test/untrustedWorkspace/integrationTests/jest.config.ts +++ b/test/razor/razorIntegrationTests/jest.config.mjs @@ -2,17 +2,16 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; -import { baseProjectConfig } from '../../../baseJestConfig'; - -export const jestIntegrationTestProjectName = 'Untrusted Integration Tests'; +import { baseProjectConfig } from '../../../baseJestConfig.mjs'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; /** * Defines a project configuration for jest integration tests. */ -const integrationTestConfig: Config = { +/** @type {import('jest').Config} */ +const integrationTestConfig = { ...baseProjectConfig, - displayName: jestIntegrationTestProjectName, + displayName: jestProjectNames.razorIntegration, roots: [''], testEnvironment: '/../../vsCodeEnvironment.ts', setupFilesAfterEnv: ['/../../vsCodeFramework.ts'], diff --git a/test/razor/razorTests/jest.config.ts b/test/razor/razorTests/jest.config.mjs similarity index 77% rename from test/razor/razorTests/jest.config.ts rename to test/razor/razorTests/jest.config.mjs index 3a24378f4e..599a3311c0 100644 --- a/test/razor/razorTests/jest.config.ts +++ b/test/razor/razorTests/jest.config.mjs @@ -2,17 +2,16 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; -import { baseProjectConfig } from '../../../baseJestConfig'; - -export const razorTestProjectName = 'Razor Unit Tests'; +import { baseProjectConfig } from '../../../baseJestConfig.mjs'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; /** * Defines a jest project configuration for Razor jest tests. */ -const razorConfig: Config = { +/** @type {import('jest').Config} */ +const razorConfig = { ...baseProjectConfig, - displayName: razorTestProjectName, + displayName: jestProjectNames.razorUnit, // We need to explicity ignore the out directory for modules - otherwise we'll get duplicate vscode module, // the TS version from the __mocks__ directory and the compiled js version from the out directory. modulePathIgnorePatterns: ['out'], diff --git a/test/runIntegrationTests.ts b/test/runIntegrationTests.ts index 7acedc7156..0711f3bb1b 100644 --- a/test/runIntegrationTests.ts +++ b/test/runIntegrationTests.ts @@ -13,7 +13,7 @@ export async function runIntegrationTests(projectName: string) { throw new Error('CODE_EXTENSIONS_PATH not set.'); } - const jestConfigPath = path.join(repoRoot, 'jest.config.ts'); + const jestConfigPath = path.join(repoRoot, 'jest.config.mjs'); const jestConfig = { config: jestConfigPath, selectProjects: [projectName], diff --git a/test/tasks/jest.config.ts b/test/tasks/jest.config.mjs similarity index 71% rename from test/tasks/jest.config.ts rename to test/tasks/jest.config.mjs index 70d7886a5e..e2c63f9df2 100644 --- a/test/tasks/jest.config.ts +++ b/test/tasks/jest.config.mjs @@ -2,17 +2,16 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; -import { baseProjectConfig } from '../../baseJestConfig'; - -export const jestTasksTestProjectName = 'Tasks Unit Tests'; +import { baseProjectConfig } from '../../baseJestConfig.mjs'; +import { jestProjectNames } from '../jestProjectNames.mjs'; /** * Defines a jest project configuration for tasks unit tests. */ -const tasksTestConfig: Config = { +/** @type {import('jest').Config} */ +const tasksTestConfig = { ...baseProjectConfig, - displayName: jestTasksTestProjectName, + displayName: jestProjectNames.tasksUnit, modulePathIgnorePatterns: ['out'], roots: ['', '../../__mocks__'], }; diff --git a/test/untrustedWorkspace/integrationTests/index.ts b/test/untrustedWorkspace/integrationTests/index.ts index ac2e6a90a2..17e719816c 100644 --- a/test/untrustedWorkspace/integrationTests/index.ts +++ b/test/untrustedWorkspace/integrationTests/index.ts @@ -4,10 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import { runIntegrationTests } from '../../runIntegrationTests'; -import { jestIntegrationTestProjectName } from './jest.config'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; export async function run() { process.env.RUNNING_INTEGRATION_TESTS = 'true'; - await runIntegrationTests(jestIntegrationTestProjectName); + await runIntegrationTests(jestProjectNames.untrustedIntegration); } diff --git a/test/omnisharp/omnisharpIntegrationTests/jest.config.ts b/test/untrustedWorkspace/integrationTests/jest.config.mjs similarity index 71% rename from test/omnisharp/omnisharpIntegrationTests/jest.config.ts rename to test/untrustedWorkspace/integrationTests/jest.config.mjs index 0845965cd7..5ef730dd3d 100644 --- a/test/omnisharp/omnisharpIntegrationTests/jest.config.ts +++ b/test/untrustedWorkspace/integrationTests/jest.config.mjs @@ -2,17 +2,16 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Config } from 'jest'; -import { baseProjectConfig } from '../../../baseJestConfig'; - -export const jestIntegrationTestProjectName = 'OmniSharp Integration Tests'; +import { baseProjectConfig } from '../../../baseJestConfig.mjs'; +import { jestProjectNames } from '../../jestProjectNames.mjs'; /** * Defines a project configuration for jest integration tests. */ -const integrationTestConfig: Config = { +/** @type {import('jest').Config} */ +const integrationTestConfig = { ...baseProjectConfig, - displayName: jestIntegrationTestProjectName, + displayName: jestProjectNames.untrustedIntegration, roots: [''], testEnvironment: '/../../vsCodeEnvironment.ts', setupFilesAfterEnv: ['/../../vsCodeFramework.ts'], diff --git a/tsconfig.json b/tsconfig.json index 9cf7928aac..626ae0bd1a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -42,7 +42,5 @@ "test", "typings", "__mocks__", - "jest.config.ts", - "baseJestConfig.ts", ], } From 22a83dfd27e99068a5adcc461fc9d7ad7534e481 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Tue, 4 Aug 2026 15:35:09 -0700 Subject: [PATCH 2/2] Emit Jest project names during compilation Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d7d912c6-9485-44f0-a1ad-ede156ecd575 --- baseJestConfig.mjs | 6 ++++-- tsconfig.json | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/baseJestConfig.mjs b/baseJestConfig.mjs index 0d444b10a3..f8f6ee8546 100644 --- a/baseJestConfig.mjs +++ b/baseJestConfig.mjs @@ -3,14 +3,16 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { readFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; import { createDefaultEsmPreset, createDefaultPreset } from 'ts-jest'; const packageJson = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')); +const tsconfig = fileURLToPath(new URL('./tsconfig.json', import.meta.url)); // The override lets tooling validate the ESM transform before the repository package type changes. const useESM = packageJson.type === 'module' || process.env.JEST_USE_ESM === 'true'; const tsJestPreset = useESM - ? createDefaultEsmPreset({ tsconfig: './tsconfig.json' }) - : createDefaultPreset({ tsconfig: './tsconfig.json' }); + ? createDefaultEsmPreset({ tsconfig }) + : createDefaultPreset({ tsconfig }); /** * Defines a base project config that we can re-use across the project specific jest configs. diff --git a/tsconfig.json b/tsconfig.json index 626ae0bd1a..837c2eab5a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,17 +30,22 @@ "sourceMap": true, "moduleResolution": "node", "moduleDetection": "force", + "allowJs": true, "strict": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "noUnusedLocals": true, "noFallthroughCasesInSwitch": true }, + "files": [ + "test/jestProjectNames.mjs", + "test/jestProjectNames.d.mts", + ], "include": [ - "src", - "tasks", - "test", - "typings", - "__mocks__", + "src/**/*.ts", + "tasks/**/*.ts", + "test/**/*.ts", + "typings/**/*.ts", + "__mocks__/**/*.ts", ], }