diff --git a/packages/core/src/shared/vscode/env.ts b/packages/core/src/shared/vscode/env.ts index 7001ae6eadb..952284b6e2c 100644 --- a/packages/core/src/shared/vscode/env.ts +++ b/packages/core/src/shared/vscode/env.ts @@ -67,10 +67,10 @@ export { extensionVersion } * * @param throwWhen Throw if minimum vscode is equal or later than this version. */ -export function isMinVscode(throwWhen?: string): boolean { +export function isMinVscode(options?: { throwWhen: string }): boolean { const minVscode = getMinVscodeVersion() - if (throwWhen && semver.gte(minVscode, throwWhen)) { - throw Error(`Min vscode ${minVscode} >= ${throwWhen}. Delete or update the code that called this.`) + if (options?.throwWhen && semver.gte(minVscode, options.throwWhen)) { + throw Error(`Min vscode ${minVscode} >= ${options.throwWhen}. Delete or update the code that called this.`) } return vscode.version.startsWith(getMinVscodeVersion()) } diff --git a/packages/core/src/test/applicationcomposer/messageHandlers/generateResourceHandler.test.ts b/packages/core/src/test/applicationcomposer/messageHandlers/generateResourceHandler.test.ts index 3521f777379..72a3a03e15d 100644 --- a/packages/core/src/test/applicationcomposer/messageHandlers/generateResourceHandler.test.ts +++ b/packages/core/src/test/applicationcomposer/messageHandlers/generateResourceHandler.test.ts @@ -8,11 +8,11 @@ import sinon from 'sinon' import { createTemplate, createWebviewContext } from '../utils' import { generateResourceHandler } from '../../../applicationcomposer/messageHandlers/generateResourceHandler' import { Command, MessageType } from '../../../applicationcomposer/types' -import * as env from '../../../shared/vscode/env' +import { isMinVscode } from '../../../shared/vscode/env' describe('generateResourceHandler', function () { it('amazon q is not installed', async function () { - if (env.isMinVscode('1.89.0')) { + if (isMinVscode({ throwWhen: '1.89.0' })) { this.skip() } const panel = await createTemplate() diff --git a/packages/core/src/test/applicationcomposer/messageHandlers/initMessageHandler.test.ts b/packages/core/src/test/applicationcomposer/messageHandlers/initMessageHandler.test.ts index b47d4ab9d68..8c2013a2da6 100644 --- a/packages/core/src/test/applicationcomposer/messageHandlers/initMessageHandler.test.ts +++ b/packages/core/src/test/applicationcomposer/messageHandlers/initMessageHandler.test.ts @@ -7,13 +7,17 @@ import assert from 'assert' import sinon from 'sinon' import { initMessageHandler } from '../../../applicationcomposer/messageHandlers/initMessageHandler' import { createTemplate, createWebviewContext } from '../utils' +import { isMinVscode } from '../../../shared/vscode/env' describe('initMessageHandler', function () { - afterEach(() => { + afterEach(function () { sinon.restore() }) - it('not connected to codewhisperer', async () => { + it('not connected to codewhisperer', async function () { + if (isMinVscode({ throwWhen: '1.89.0' })) { + this.skip() + } const panel = await createTemplate() const postMessageSpy = sinon.spy(panel.webview, 'postMessage') const context = await createWebviewContext({