diff --git a/common/tools/dev-tool/src/commands/run/testVitest.ts b/common/tools/dev-tool/src/commands/run/testVitest.ts index 78a11dffb42c..a9ba97055d21 100644 --- a/common/tools/dev-tool/src/commands/run/testVitest.ts +++ b/common/tools/dev-tool/src/commands/run/testVitest.ts @@ -6,6 +6,8 @@ import { leafCommand, makeCommandInfo } from "../../framework/command"; import { runTestsWithProxyTool } from "../../util/testUtils"; import { createPrinter } from "../../util/printer"; +const log = createPrinter("test:vitest"); + export const commandInfo = makeCommandInfo( "test:vitest", "runs tests using vitest with the default and the provided options; starts the proxy-tool in record and playback modes", @@ -16,7 +18,7 @@ export const commandInfo = makeCommandInfo( default: false, description: "whether to disable launching test-proxy", }, - "browser": { + browser: { shortName: "br", kind: "boolean", default: false, @@ -25,24 +27,38 @@ export const commandInfo = makeCommandInfo( }, ); +async function playwrightInstall(): Promise { + const { result } = concurrently([ + { + command: "npx playwright install", + name: "playwright install", + }, + ]); + + await result; + log.info("playwright browsers installed"); +} + export default leafCommand(commandInfo, async (options) => { - const args = options["browser"] ? "-c vitest.browser.config.mts": ""; + if (options["browser"]) { + await playwrightInstall(); + } + + const args = options["browser"] ? "-c vitest.browser.config.mts" : ""; const updatedArgs = options["--"]?.map((opt) => opt.includes("**") && !opt.startsWith("'") && !opt.startsWith('"') ? `"${opt}"` : opt, ); - const vitestArgs = updatedArgs?.length - ? updatedArgs.join(" ") - : ''; + const vitestArgs = updatedArgs?.length ? updatedArgs.join(" ") : ""; const command = { command: `vitest ${args} ${vitestArgs}`, - name: "vi-tests", + name: "vitest", }; if (!options["no-test-proxy"]) { return runTestsWithProxyTool(command); } - createPrinter("test-info").info("Running vitest without test-proxy"); + log.info("Running vitest without test-proxy"); await concurrently([command]).result; return true; }); diff --git a/sdk/core/core-rest-pipeline/package.json b/sdk/core/core-rest-pipeline/package.json index 08f4005148d1..01689a2e8aef 100644 --- a/sdk/core/core-rest-pipeline/package.json +++ b/sdk/core/core-rest-pipeline/package.json @@ -38,7 +38,7 @@ "test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser", "test:node": "npm run unit-test:node && npm run integration-test:node", "test": "npm run test:node && npm run test:browser", - "unit-test:browser": "playwright install && dev-tool run test:vitest --no-test-proxy=true --browser=true", + "unit-test:browser": "dev-tool run test:vitest --no-test-proxy=true --browser=true", "unit-test:node": "dev-tool run test:vitest --no-test-proxy=true", "unit-test": "npm run unit-test:node && npm run unit-test:browser" }, diff --git a/sdk/core/core-util/package.json b/sdk/core/core-util/package.json index 4c53e04fe5f4..b58243b76013 100644 --- a/sdk/core/core-util/package.json +++ b/sdk/core/core-util/package.json @@ -33,7 +33,7 @@ "test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser", "test:node": "npm run unit-test:node && npm run integration-test:node", "test": "npm run test:node && npm run test:browser", - "unit-test:browser": "playwright install && dev-tool run test:vitest --no-test-proxy=true --browser=true", + "unit-test:browser": "dev-tool run test:vitest --no-test-proxy=true --browser=true", "unit-test:node": "dev-tool run test:vitest --no-test-proxy=true", "unit-test": "npm run unit-test:node && npm run unit-test:browser" },