diff --git a/.github/workflows/pr-gated.yml b/.github/workflows/pr-gated.yml index 401110bb..54583f5b 100644 --- a/.github/workflows/pr-gated.yml +++ b/.github/workflows/pr-gated.yml @@ -13,18 +13,18 @@ jobs: - name: setup node uses: actions/setup-node@v3 with: - node-version: "18.15" + node-version: "18.17" - run: node -v - run: npm ci - run: npm run audit - run: npm run test:unit-test - run: npm run vsix - # - name: retry 5 times e2e test cases - # uses: nick-fields/retry@v2 - # with: - # timeout_minutes: 10 - # max_attempts: 5 - # command: npm run test:e2e + - name: retry 5 times e2e test cases + uses: nick-fields/retry@v2 + with: + timeout_minutes: 10 + max_attempts: 5 + command: npm run test:e2e - name: upload VSIX to artifactory uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index dd7ca9c3..94c9aaff 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -54,7 +54,7 @@ jobs: - name: setup node uses: actions/setup-node@v3 with: - node-version: "18.15" + node-version: "18.17" - run: node -v - run: npm ci env: diff --git a/.pipelines/pr-pipeline.yml b/.pipelines/pr-pipeline.yml index 1a659c3b..5aeb880d 100644 --- a/.pipelines/pr-pipeline.yml +++ b/.pipelines/pr-pipeline.yml @@ -4,75 +4,75 @@ # https://docs.microsoft.com/azure/devops/pipelines/languages/javascript trigger: - - main + - main pr: - - main + - main pool: - vmImage: "windows-latest" + vmImage: "windows-latest" variables: - CI: 'true' + CI: "true" steps: - - task: NodeTool@0 - inputs: - versionSpec: "18.15.0" - displayName: "Install Node.js" + - task: NodeTool@0 + inputs: + versionSpec: "18.17.0" + displayName: "Install Node.js" - - task: Npm@1 - displayName: "npm clean-install" - inputs: - command: "ci" + - task: Npm@1 + displayName: "npm clean-install" + inputs: + command: "ci" - - task: Npm@1 - displayName: "audit" - inputs: - command: "custom" - customCommand: "run audit" + - task: Npm@1 + displayName: "audit" + inputs: + command: "custom" + customCommand: "run audit" - - task: Npm@1 - displayName: "npm unit test" - inputs: - command: "custom" - customCommand: "run test:unit-test" + - task: Npm@1 + displayName: "npm unit test" + inputs: + command: "custom" + customCommand: "run test:unit-test" - - task: Npm@1 - displayName: "build VSIX" - inputs: - command: "custom" - customCommand: "run vsix" + - task: Npm@1 + displayName: "build VSIX" + inputs: + command: "custom" + customCommand: "run vsix" - # - task: Npm@1 - # displayName: "npm e2e test" - # enabled: 'true' - # retryCountOnTaskFailure: 5 - # continueOnError: 'true' - # inputs: - # command: "custom" - # customCommand: "run test:e2e" + # - task: Npm@1 + # displayName: "npm e2e test" + # enabled: 'true' + # retryCountOnTaskFailure: 5 + # continueOnError: 'true' + # inputs: + # command: "custom" + # customCommand: "run test:e2e" - - task: PoliCheck@1 - inputs: - inputType: "Basic" - targetType: "F" - targetArgument: "src" - result: "PoliCheck.xml" + - task: PoliCheck@1 + inputs: + inputType: "Basic" + targetType: "F" + targetArgument: "src" + result: "PoliCheck.xml" - - task: CopyFiles@2 - displayName: "copy VSIX to ArtifactStagingDirectory" - inputs: - contents: '$(System.DefaultWorkingDirectory)/*.vsix' - targetFolder: $(Build.ArtifactStagingDirectory) + - task: CopyFiles@2 + displayName: "copy VSIX to ArtifactStagingDirectory" + inputs: + contents: "$(System.DefaultWorkingDirectory)/*.vsix" + targetFolder: $(Build.ArtifactStagingDirectory) - - task: PublishBuildArtifacts@1 - displayName: "drop ArtifactStagingDirectory" - inputs: - PathtoPublish: $(Build.ArtifactStagingDirectory) - ArtifactName: VSIX + - task: PublishBuildArtifacts@1 + displayName: "drop ArtifactStagingDirectory" + inputs: + PathtoPublish: $(Build.ArtifactStagingDirectory) + ArtifactName: VSIX - - task: PublishBuildArtifacts@1 - displayName: "publish policheck results" - inputs: - PathtoPublish: "$(System.DefaultWorkingDirectory)/../_sdt/logs/PoliCheck" - ArtifactName: PoliCheck + - task: PublishBuildArtifacts@1 + displayName: "publish policheck results" + inputs: + PathtoPublish: "$(System.DefaultWorkingDirectory)/../_sdt/logs/PoliCheck" + ArtifactName: PoliCheck diff --git a/.vscode-test.mjs b/.vscode-test.mjs new file mode 100644 index 00000000..75a56d35 --- /dev/null +++ b/.vscode-test.mjs @@ -0,0 +1,5 @@ +import { defineConfig } from '@vscode/test-cli'; + +export default defineConfig({ + files: 'out/src/test/**/*.test.js', +}); diff --git a/.vscode/extensions.json b/.vscode/extensions.json index f36bb36b..055f18a2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,10 @@ { // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format - "recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher", "esbenp.prettier-vscode"] + "recommendations": [ + "dbaeumer.vscode-eslint", + "amodio.tsl-problem-matcher", + "esbenp.prettier-vscode", + "ms-vscode.extension-test-runner" + ] } diff --git a/.vscode/launch.json b/.vscode/launch.json index ca97bf65..ac4031bf 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -33,14 +33,16 @@ } }, { - "name": "Extension Tests", + "name": "Extension UI Tests", "type": "extensionHost", "request": "launch", + "runtimeExecutable": "${execPath}", "args": [ "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" + "--extensionTestsPath=${workspaceFolder}/out/src/test/suite/index", + "--extensions-dir=${workspaceFolder}/.vscode-test/extensions" ], - "outFiles": ["${workspaceFolder}/out/**/*.js", "${workspaceFolder}/dist/**/*.js"], + "outFiles": ["${workspaceFolder}/out/**/*.js"], "preLaunchTask": "tasks: watch-tests" } ] diff --git a/.vscode/settings.json b/.vscode/settings.json index 28e5a97e..03baf4fc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,5 +10,6 @@ }, // Turn off tsc task auto detection since we have the necessary tasks as npm scripts "typescript.tsc.autoDetect": "off", - "editor.formatOnSave": true + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 854be99d..af8288f5 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -3,7 +3,7 @@ { "version": "2.0.0", "tasks": [ - { + { "label": "Watch_VSC_PQ_SDK", "type": "npm", "script": "watch", @@ -36,26 +36,26 @@ "promptOnClose": true, "isBackground": true, "problemMatcher": { - "owner": "webpack", - "severity": "error", - "fileLocation": "absolute", - "pattern": [ - { - "regexp": "ERROR in (.*)", - "file": 1 - }, - { - "regexp": "\\((\\d+),(\\d+)\\):(.*)", - "line": 1, - "column": 2, - "message": 3 + "owner": "webpack", + "severity": "error", + "fileLocation": "absolute", + "pattern": [ + { + "regexp": "ERROR in (.*)", + "file": 1 + }, + { + "regexp": "\\((\\d+),(\\d+)\\):(.*)", + "line": 1, + "column": 2, + "message": 3 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": "Compiling\\.\\.\\.", + "endsPattern": "compiled successfully in" } - ], - "background": { - "activeOnStart": true, - "beginsPattern": "Compiling\\.\\.\\.", - "endsPattern": "compiled successfully in" - } }, "options": { "cwd": "${workspaceFolder}/webviews/pq-test-result-view" @@ -63,14 +63,11 @@ }, { "label": "Develop_Extensions", - "dependsOn": [ - "Watch_VSC_PQ_SDK", - "Dev_PQTest_Result_WebView" - ] + "dependsOn": ["Watch_VSC_PQ_SDK", "Dev_PQTest_Result_WebView"] }, { "label": "tasks: watch-tests", - "dependsOn": ["Develop_Extensions", "npm: watch-tests"], + "dependsOn": ["Watch_VSC_PQ_SDK", "Dev_PQTest_Result_WebView", "npm: watch-tests"], "problemMatcher": [] } ] diff --git a/package-lock.json b/package-lock.json index 4a4a5e53..b7d127b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-powerquery-sdk", - "version": "0.3.0", + "version": "0.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vscode-powerquery-sdk", - "version": "0.3.0", + "version": "0.3.1", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -26,7 +26,7 @@ "@typescript-eslint/parser": "^5.62.0", "@vscode/debugadapter": "^1.65.0", "@vscode/debugadapter-testsupport": "^1.65.0", - "@vscode/test-electron": "^1.6.2", + "@vscode/test-electron": "^2.3.9", "@vscode/vsce": "^2.24.0", "chai": "^4.4.1", "eslint": "^8.57.0", @@ -52,8 +52,8 @@ "webpack-cli": "^4.10.0" }, "engines": { - "node": ">=18.0.0 <=18.15.0", - "vscode": "^1.62.0" + "node": ">=18.17.0", + "vscode": "^1.87.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -894,18 +894,18 @@ "dev": true }, "node_modules/@vscode/test-electron": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-1.6.2.tgz", - "integrity": "sha512-W01ajJEMx6223Y7J5yaajGjVs1QfW3YGkkOJHVKfAMEqNB1ZHN9wCcViehv5ZwVSSJnjhu6lYEYgwBdHtCxqhQ==", + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.9.tgz", + "integrity": "sha512-z3eiChaCQXMqBnk2aHHSEkobmC2VRalFQN0ApOAtydL172zXGxTwGrRtviT5HnUB+Q+G3vtEYFtuQkYqBzYgMA==", "dev": true, "dependencies": { "http-proxy-agent": "^4.0.1", "https-proxy-agent": "^5.0.0", - "rimraf": "^3.0.2", - "unzipper": "^0.10.11" + "jszip": "^3.10.1", + "semver": "^7.5.2" }, "engines": { - "node": ">=8.9.3" + "node": ">=16" } }, "node_modules/@vscode/vsce": { @@ -3157,9 +3157,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", - "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", diff --git a/package.json b/package.json index 83fbc696..04cf3436 100644 --- a/package.json +++ b/package.json @@ -2,20 +2,19 @@ "name": "vscode-powerquery-sdk", "displayName": "Power Query SDK", "description": "Power Query Connector SDK", - "version": "0.3.0", + "version": "0.3.1", "author": "Microsoft Corporation", "license": "MIT", "homepage": "https://github.com/microsoft/vscode-powerquery-sdk#readme", "repository": { "type": "git", - "url": "git+https://github.com/microsoft/vscode-powerquery-sdk.git", - "directory": "client" + "url": "git+https://github.com/microsoft/vscode-powerquery-sdk.git" }, "issues": { "url": "https://github.com/microsoft/vscode-powerquery-sdk/issues" }, "engines": { - "node": ">=18.0.0 <=18.15.0", + "node": ">=18.17.0", "vscode": "^1.87.0" }, "capabilities": { @@ -29,17 +28,6 @@ "activationEvents": [ "onStartupFinished", "onCommand:workbench.action.tasks.runTask", - "onCommand:powerquery.sdk.tools.CreateNewProjectCommand", - "onCommand:powerquery.sdk.tools.SeizePqTestCommand", - "onCommand:powerquery.sdk.tools.SetupCurrentWorkspaceCommand", - "onCommand:powerquery.sdk.tools.DeleteCredentialCommand", - "onCommand:powerquery.sdk.tools.DisplayExtensionInfoCommand", - "onCommand:powerquery.sdk.tools.ListCredentialCommand", - "onCommand:powerquery.sdk.tools.GenerateAndSetCredentialCommand", - "onCommand:powerquery.sdk.tools.RefreshCredentialCommand", - "onCommand:powerquery.sdk.tools.RunTestBatteryCommand", - "onCommand:powerquery.sdk.tools.TestConnectionCommand", - "onView:powerquery.sdk.tools.LifeCycleTaskTreeView", "onWebviewPanel:powerquery.sdk.tools.ResultWebView", "onLanguage:powerquery" ], @@ -374,12 +362,13 @@ "pretest": "rimraf out && npm run compile-tests && npm run compile && npm run lint", "audit": "npm audit --omit=dev", "lint": "eslint src --ext ts", - "test:unit-test": "mocha -r ts-node/register -s 0 \"./unit-tests/**/*.spec.ts\"", - "test:e2e": "npm run compile-tests && ts-node scripts/test-e2e.ts", - "test:e2e:nobuild": "ts-node scripts/test-e2e.ts", "test": "npm run test:unit-test && npm run test:e2e", + "test:unit-test": "mocha -r ts-node/register -s 0 \"./unit-tests/**/*.spec.ts\"", + "test:e2e": "npm run compile-tests && npm run test-ui", "vsix": "npx vsce package --target win32-x64", - "code-install": "ts-node scripts/install.ts" + "code-install": "ts-node scripts/install.ts", + "test-ui": "node ./out/src/test/runTest.js", + "test:e2e:old": "npm run compile-tests && ts-node scripts/test-e2e.ts" }, "dependencies": { "axios": "^1.6.7", @@ -398,7 +387,7 @@ "@typescript-eslint/parser": "^5.62.0", "@vscode/debugadapter": "^1.65.0", "@vscode/debugadapter-testsupport": "^1.65.0", - "@vscode/test-electron": "^1.6.2", + "@vscode/test-electron": "^2.3.9", "@vscode/vsce": "^2.24.0", "chai": "^4.4.1", "eslint": "^8.57.0", @@ -433,4 +422,4 @@ "pre-commit": "lint-staged" } } -} \ No newline at end of file +} diff --git a/src/constants/PowerQuerySdkExtension.ts b/src/constants/PowerQuerySdkExtension.ts index a152629f..67ebf8ae 100644 --- a/src/constants/PowerQuerySdkExtension.ts +++ b/src/constants/PowerQuerySdkExtension.ts @@ -57,6 +57,7 @@ const ConfigPathToTestConnectionFile: string = "}"; const PQLanguageId: string = "powerquery"; +const PQLanguageServiceExtensionId: string = "powerquery.vscode-powerquery"; const OutputChannelName: string = "Power Query SDK"; const PowerQueryTaskType: string = PQLanguageId; const PQDebugType: string = PowerQueryTaskType; @@ -109,6 +110,7 @@ export const ExtensionConstants = Object.freeze({ ConfigPathToConnector, ConfigPathToTestConnectionFile, PQLanguageId, + PQLanguageServiceExtensionId, OutputChannelName, PowerQueryTaskType, PQDebugType, diff --git a/src/extension.ts b/src/extension.ts index 7aa4c7ed..cc0986f8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -11,6 +11,7 @@ import { convertExtensionInfoToLibraryJson, ExtensionInfo, IPQTestService } from import { getFirstWorkspaceFolder, maybeHandleNewWorkspaceCreated } from "./utils/vscodes"; import { activateMQueryDebug } from "./debugAdaptor/activateMQueryDebug"; import { ExtensionConfigurations } from "./constants/PowerQuerySdkConfiguration"; +import { ExtensionConstants } from "./constants/PowerQuerySdkExtension"; import { GlobalEventBus } from "./GlobalEventBus"; import { IDisposable } from "./common/Disposable"; import { LifecycleCommands } from "./commands/LifecycleCommands"; @@ -24,7 +25,7 @@ import { PqTestResultViewPanel } from "./panels/PqTestResultViewPanel"; export function activate(vscExtCtx: vscode.ExtensionContext): void { // eslint-disable-next-line @typescript-eslint/no-explicit-any - const vscPowerQuery: any = vscode.extensions.getExtension("powerquery.vscode-powerquery")?.exports; + const vscPowerQuery: any = vscode.extensions.getExtension(ExtensionConstants.PQLanguageServiceExtensionId)?.exports; const useServiceHost: boolean = ExtensionConfigurations.featureUseServiceHost; diff --git a/src/test/TestUtils.ts b/src/test/TestUtils.ts new file mode 100644 index 00000000..52795b72 --- /dev/null +++ b/src/test/TestUtils.ts @@ -0,0 +1,35 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the MIT license found in the + * LICENSE file in the root of this projects source tree. + */ + +import * as assert from "assert"; +import * as vscode from "vscode"; + +import { extensionId, extensionPublisher } from "./common"; + +const defaultTestPromiseTimeout: number = 5000; + +const sdkExtensionId: string = `${extensionPublisher}.${extensionId}`; + +export function CreateAsyncTestResult(fn: () => void): Promise { + return new Promise((resolve, reject) => { + fn(); + resolve(); + + setTimeout(() => { + reject(new Error(`TestResult timeout exceeded: ${defaultTestPromiseTimeout}ms`)); + }, defaultTestPromiseTimeout); + }); +} + +export async function activateExtension(): Promise { + const extension: vscode.Extension = + vscode.extensions.getExtension(sdkExtensionId) || assert.fail(`Extension not found: ${sdkExtensionId}`); + + if (!extension.isActive) { + await extension.activate(); + } +} diff --git a/src/test/common.ts b/src/test/common.ts index 8144cfee..dbf0d67a 100644 --- a/src/test/common.ts +++ b/src/test/common.ts @@ -26,6 +26,7 @@ export const AWAIT_INTERVAL: number = 5e3; export const extensionId: string = rootPackageJson.name; export const extensionVersion: string = rootPackageJson.version; export const extensionPublisher: string = rootPackageJson.publisher; +export const extensionLanguageServiceId: string = ExtensionConstants.PQLanguageServiceExtensionId; export const homeDirectory = os.homedir(); export const extensionDevelopmentPath = path.resolve(__dirname, "../../../"); diff --git a/src/test/runTest.ts b/src/test/runTest.ts new file mode 100644 index 00000000..1e4916bc --- /dev/null +++ b/src/test/runTest.ts @@ -0,0 +1,37 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the MIT license found in the + * LICENSE file in the root of this projects source tree. + */ + +import * as cp from "child_process"; +import * as path from "path"; +import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath, runTests } from "@vscode/test-electron"; + +async function main(): Promise { + try { + const extensionDevelopmentPath = path.resolve(__dirname, "../../../"); + const extensionTestsPath = path.resolve(__dirname, "./suite/index"); + const vscodeExecutablePath = await downloadAndUnzipVSCode("stable"); + const [cliPath, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath); + + // Install powerquery language service package dependency. + cp.spawnSync(cliPath, [...args, "--install-extension", "powerquery.vscode-powerquery"], { + encoding: "utf-8", + stdio: "inherit", + }); + + // Run the extension test + await runTests({ + vscodeExecutablePath, + extensionDevelopmentPath, + extensionTestsPath, + }); + } catch (err) { + console.error("Failed to run tests"); + process.exit(1); + } +} + +main(); diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts new file mode 100644 index 00000000..fa049e3e --- /dev/null +++ b/src/test/suite/extension.test.ts @@ -0,0 +1,33 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the MIT license found in the + * LICENSE file in the root of this projects source tree. + */ + +import * as assert from "assert"; +import * as vscode from "vscode"; + +import * as TestUtils from "../TestUtils"; + +import { extensionLanguageServiceId } from "../common"; + +const languageServiceId: string = extensionLanguageServiceId; + +suite("Extension Test Suite", () => { + suiteSetup(TestUtils.activateExtension); + + test("Language service extension", async () => { + const languageServiceExtension = + vscode.extensions.getExtension(languageServiceId) || + assert.fail(`Failed to get language service extension: ${languageServiceId}`); + + if (!languageServiceExtension.isActive) { + await languageServiceExtension.activate(); + } + + await TestUtils.CreateAsyncTestResult(() => { + assert.equal(languageServiceExtension.isActive, true, "Language service extension failed to activate"); + }); + }); +}); diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts new file mode 100644 index 00000000..81c89fa8 --- /dev/null +++ b/src/test/suite/index.ts @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the MIT license found in the + * LICENSE file in the root of this projects source tree. + */ + +import * as path from "path"; +import glob from "glob"; +import Mocha from "mocha"; + +export function run(): Promise { + // Create the mocha test + const mocha = new Mocha({ + ui: "tdd", + color: true, + }); + + const testsRoot = path.resolve(__dirname, ".."); + + return new Promise((c, e) => { + glob("**/**.test.js", { cwd: testsRoot }, (err, files) => { + if (err) { + return e(err); + } + + // Add files to the test suite + files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); + + try { + // Run the mocha test + mocha.run(failures => { + if (failures > 0) { + e(new Error(`${failures} tests failed.`)); + } else { + c(); + } + }); + } catch (err) { + e(err); + } + }); + }); +} diff --git a/src/test/suite/project.test.ts b/src/test/suite/project.test.ts new file mode 100644 index 00000000..d2600b1d --- /dev/null +++ b/src/test/suite/project.test.ts @@ -0,0 +1,33 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the MIT license found in the + * LICENSE file in the root of this projects source tree. + */ + +import * as assert from "assert"; +import * as vscode from "vscode"; + +import * as TestUtils from "../TestUtils"; + +import { LifecycleCommands } from "../../../src/commands/LifecycleCommands"; + +// import { makeOneTmpDir } from "../../utils/osUtils"; + +suite("New extension project Tests", () => { + suiteSetup(TestUtils.activateExtension); + + // const newExtensionName: string = "FirstConn"; + // const oneTmpDir: string | undefined = makeOneTmpDir(); + + test("New extension project command exists", async () => { + await TestUtils.CreateAsyncTestResult(() => { + assert.ok( + vscode.commands + .getCommands(true) + .then(commands => commands.includes(LifecycleCommands.CreateNewProjectCommand)), + `${LifecycleCommands.CreateNewProjectCommand} command not found`, + ); + }); + }); +}); diff --git a/src/test/utils/pqSdkTestOutputChannel.ts b/src/test/utils/pqSdkTestOutputChannel.ts index f58cc53e..a18f3de4 100644 --- a/src/test/utils/pqSdkTestOutputChannel.ts +++ b/src/test/utils/pqSdkTestOutputChannel.ts @@ -8,11 +8,21 @@ import type { PqSdkOutputChannelLight } from "../../features/PqSdkOutputChannel"; export class PqSdkTestOutputChannel implements PqSdkOutputChannelLight { + private readonly _lines: string[] = []; + public appendInfoLine(value: string): void { - console.info(`\t\t[test] ${value}`); + this._lines.push(`\t\t[test][info] ${value}`); } public appendErrorLine(value: string): void { - console.error(`\t\t[test] ${value}`); + this._lines.push(`\t\t[test][error] ${value}`); + } + + public emit(): void { + for (const line of this._lines) { + console.log(line); + } + + this._lines.length = 0; } } diff --git a/tsconfig.json b/tsconfig.json index e7bc584b..02203a62 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "baseUrl": ".", - "module": "commonjs", + "module": "commonjs", // TODO: should this be "Node16"? "target": "ES2020", "lib": ["ES2020"], "sourceMap": true, diff --git a/unit-tests/common/nuget/NugetCommandService.spec.ts b/unit-tests/common/nuget/NugetCommandService.spec.ts index a20def4c..d3b9b620 100644 --- a/unit-tests/common/nuget/NugetCommandService.spec.ts +++ b/unit-tests/common/nuget/NugetCommandService.spec.ts @@ -18,7 +18,7 @@ const expect = chai.expect; const SdkPackageName = "Microsoft.PowerQuery.SdkTools"; const InternalNugetFeed = "https://powerbi.pkgs.visualstudio.com/_packaging/PowerBiComponents/nuget/v3/index.json"; -describe("NugetCommandService unit testes", () => { +describe("NugetCommandService unit tests", () => { const nugetPath = findExecutable("nuget", [".exe", ""]); // disable these test cases for the ci due to auth config diff --git a/unit-tests/common/nuget/NugetHttpService.spec.ts b/unit-tests/common/nuget/NugetHttpService.spec.ts index 50bf24c2..cabc6ee9 100644 --- a/unit-tests/common/nuget/NugetHttpService.spec.ts +++ b/unit-tests/common/nuget/NugetHttpService.spec.ts @@ -20,7 +20,10 @@ const expect = chai.expect; const SdkPackageName = "Microsoft.PowerQuery.SdkTools"; describe("NugetHttpService unit tests", () => { - const nugetHttpService = new NugetHttpService(new PqSdkTestOutputChannel()); + const testOutputChannel = new PqSdkTestOutputChannel(); + const nugetHttpService = new NugetHttpService(testOutputChannel); + + afterEach(() => testOutputChannel.emit()); it("getPackageReleasedVersions v1", async () => { const res = await nugetHttpService.getPackageReleasedVersions(SdkPackageName); diff --git a/webviews/pq-test-result-view/package-lock.json b/webviews/pq-test-result-view/package-lock.json index 21fb7ba4..2abb10a2 100644 --- a/webviews/pq-test-result-view/package-lock.json +++ b/webviews/pq-test-result-view/package-lock.json @@ -56,7 +56,7 @@ "webpack-merge": "^5.10.0" }, "engines": { - "node": ">=18.0.0" + "node": ">=18.17.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -6644,9 +6644,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", - "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "dev": true, "funding": [ { diff --git a/webviews/pq-test-result-view/package.json b/webviews/pq-test-result-view/package.json index a1b2692c..8bbdefda 100644 --- a/webviews/pq-test-result-view/package.json +++ b/webviews/pq-test-result-view/package.json @@ -10,7 +10,7 @@ "audit": "npm audit" }, "engines": { - "node": ">=18.0.0" + "node": ">=18.17.0" }, "dependencies": { "@fluentui/react": "^8.115.7",