diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index cfe5a19f3191..80cbd16e48bc 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3154,8 +3154,8 @@ packages: resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} dev: false - /@ts-morph/common@0.22.0: - resolution: {integrity: sha512-HqNBuV/oIlMKdkLshXd1zKBqNQCsuPEsgQOkfFQ/eUKjRlwndXW1AjN9LVkBEIukm00gGXSRmfkl0Wv5VXLnlw==} + /@ts-morph/common@0.23.0: + resolution: {integrity: sha512-m7Lllj9n/S6sOkCkRftpM7L24uvmfXQFedlW/4hENcuJH1HHm9u5EgxZb9uVjQSCGrbBWBkOGgcTxNg36r6ywA==} dependencies: fast-glob: 3.3.2 minimatch: 9.0.3 @@ -4553,8 +4553,8 @@ packages: engines: {node: '>=0.8'} dev: false - /code-block-writer@12.0.0: - resolution: {integrity: sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==} + /code-block-writer@13.0.1: + resolution: {integrity: sha512-c5or4P6erEA69TxaxTNcHUNcIn+oyxSRTOWV+pSYF+z4epXqNvwvJ70XPGjPNgue83oAFAPBRQYwpAJ/Hpe/Sg==} dev: false /color-convert@1.9.3: @@ -9516,11 +9516,11 @@ packages: hasBin: true dev: false - /ts-morph@21.0.1: - resolution: {integrity: sha512-dbDtVdEAncKctzrVZ+Nr7kHpHkv+0JDJb2MjjpBaj8bFeCkePU9rHfMklmhuLFnpeq/EJZk2IhStY6NzqgjOkg==} + /ts-morph@22.0.0: + resolution: {integrity: sha512-M9MqFGZREyeb5fTl6gNHKZLqBQA0TjA1lea+CR48R8EBTDuWrNqW6ccC5QvjNR4s6wDumD3LTCjOFSp9iwlzaw==} dependencies: - '@ts-morph/common': 0.22.0 - code-block-writer: 12.0.0 + '@ts-morph/common': 0.23.0 + code-block-writer: 13.0.1 dev: false /ts-node@10.9.2(@types/node@16.18.87)(typescript@5.3.3): @@ -18746,7 +18746,7 @@ packages: dev: false file:projects/dev-tool.tgz: - resolution: {integrity: sha512-nG09YWhjmXYNV6+T5bq5NgXbetMsZVCsTumlZbkOnyq7pM435jJTDYSC2nsBxvDCYGkqhOQNB2N6gsNs9gZGag==, tarball: file:projects/dev-tool.tgz} + resolution: {integrity: sha512-g2sD7pNnn7rPJrvryHfXFz/s/IGrGDUBZMXOsyAdH2McMYMOPqIY0cfqOxXEAKY89AWo2yr6h6taU6bvywZDQg==, tarball: file:projects/dev-tool.tgz} name: '@rush-temp/dev-tool' version: 0.0.0 dependencies: @@ -18767,6 +18767,7 @@ packages: '@types/mocha': 10.0.6 '@types/node': 18.19.22 '@types/semver': 7.5.8 + '@vitest/coverage-istanbul': 1.3.1(vitest@1.3.1) archiver: 7.0.1 autorest: 3.7.1 builtin-modules: 3.3.0 @@ -18792,17 +18793,29 @@ packages: rollup-plugin-visualizer: 5.12.0(rollup@4.12.1) semver: 7.6.0 strip-json-comments: 5.0.1 - ts-morph: 21.0.1 + ts-morph: 22.0.0 ts-node: 10.9.2(@types/node@18.19.22)(typescript@5.3.3) tslib: 2.6.2 typescript: 5.3.3 + vitest: 1.3.1(@types/node@18.19.22)(@vitest/browser@1.3.1) yaml: 2.4.1 transitivePeerDependencies: + - '@edge-runtime/vm' - '@swc/core' - '@swc/wasm' + - '@vitest/browser' + - '@vitest/ui' - bufferutil - debug + - happy-dom + - jsdom + - less + - lightningcss + - sass + - stylus + - sugarss - supports-color + - terser - utf-8-validate dev: false diff --git a/common/tools/dev-tool/package.json b/common/tools/dev-tool/package.json index 1bc85578841a..20be41c18a84 100644 --- a/common/tools/dev-tool/package.json +++ b/common/tools/dev-tool/package.json @@ -25,7 +25,7 @@ "pack": "npm pack 2>&1", "prebuild": "npm run clean", "unit-test": "npm run unit-test:node", - "unit-test:node": "mocha --require ts-node/register test/**/*.spec.ts test/*.spec.ts", + "unit-test:node": "vitest", "unit-test:browser": "echo skipped", "build:samples": "echo Skipped.", "test": "echo Skipped." @@ -60,35 +60,29 @@ "rollup": "^4.0.0", "rollup-plugin-polyfill-node": "^0.13.0", "rollup-plugin-visualizer": "^5.9.3", - "semver": "^7.5.4", + "semver": "^7.6.0", "strip-json-comments": "^5.0.1", + "ts-morph": "^22.0.0", "ts-node": "^10.9.1", "tslib": "^2.2.0", "typescript": "~5.3.3", - "yaml": "^2.3.4", - "ts-morph": "^21.0.0" + "yaml": "^2.3.4" }, "devDependencies": { - "@microsoft/api-extractor": "^7.31.1", + "@microsoft/api-extractor": "^7.42.3", "@types/archiver": "~6.0.2", - "@types/chai": "^4.1.6", - "@types/chai-as-promised": "^7.1.0", - "@types/decompress": "^4.2.4", + "@types/decompress": "^4.2.7", "@types/fs-extra": "^11.0.4", "@types/minimist": "^1.2.5", - "@types/mocha": "^10.0.0", "@types/node": "^18.0.0", - "@types/semver": "^7.5.6", - "autorest": "^3.5.1", + "@types/semver": "^7.5.8", + "@vitest/coverage-istanbul": "^1.3.1", + "autorest": "^3.7.1", "builtin-modules": "^3.1.0", - "c8": "^8.0.1", - "chai": "^4.2.0", - "chai-as-promised": "^7.1.1", "cross-env": "^7.0.3", "eslint": "^8.54.0", - "karma": "^6.4.2", "mkdirp": "^3.0.1", - "mocha": "^10.0.0", - "rimraf": "^5.0.5" + "rimraf": "^5.0.5", + "vitest": "^1.3.1" } } diff --git a/common/tools/dev-tool/src/commands/about.ts b/common/tools/dev-tool/src/commands/about.ts index 15a44fa07596..617e6a82e0e3 100644 --- a/common/tools/dev-tool/src/commands/about.ts +++ b/common/tools/dev-tool/src/commands/about.ts @@ -2,7 +2,6 @@ // Licensed under the MIT license import chalk from "chalk"; - import { baseCommands, baseCommandInfo } from "."; import { resolveProject } from "../util/resolveProject"; import { createPrinter } from "../util/printer"; diff --git a/common/tools/dev-tool/src/commands/admin/create-migration.ts b/common/tools/dev-tool/src/commands/admin/create-migration.ts index 85cf8d08c94c..b8716f9e4d16 100644 --- a/common/tools/dev-tool/src/commands/admin/create-migration.ts +++ b/common/tools/dev-tool/src/commands/admin/create-migration.ts @@ -4,13 +4,10 @@ import path from "node:path"; import readline from "node:readline"; import { spawnSync } from "node:child_process"; - import { leafCommand, makeCommandInfo } from "../../framework/command"; import migrationTemplate, { MigrationTemplate } from "../../templates/migration"; import { createPrinter } from "../../util/printer"; - import { ensureDir, pathExists, writeFile } from "fs-extra"; - import { format } from "../../util/prettier"; const log = createPrinter("create-migration"); diff --git a/common/tools/dev-tool/src/commands/admin/list/packages.ts b/common/tools/dev-tool/src/commands/admin/list/packages.ts index 0decbf81e5e0..9408d6ea2524 100644 --- a/common/tools/dev-tool/src/commands/admin/list/packages.ts +++ b/common/tools/dev-tool/src/commands/admin/list/packages.ts @@ -2,12 +2,9 @@ // Licensed under the MIT license. import { leafCommand, makeCommandInfo } from "../../../framework/command"; - -import path from "path"; +import path from "node:path"; import { resolveRoot } from "../../../util/resolveProject"; - -import { readFile } from "fs/promises"; - +import { readFile } from "node:fs/promises"; import stripJsonComments from "strip-json-comments"; export const commandInfo = makeCommandInfo("packages", "list packages defined in the monorepo", { diff --git a/common/tools/dev-tool/src/commands/admin/list/service-folders.ts b/common/tools/dev-tool/src/commands/admin/list/service-folders.ts index d766a9dfa19f..614f9bda4ff4 100644 --- a/common/tools/dev-tool/src/commands/admin/list/service-folders.ts +++ b/common/tools/dev-tool/src/commands/admin/list/service-folders.ts @@ -2,6 +2,9 @@ // Licensed under the MIT license. import { leafCommand, makeCommandInfo } from "../../../framework/command"; +import path from "node:path"; +import { resolveRoot } from "../../../util/resolveProject"; +import { readdir } from "node:fs/promises"; export const commandInfo = makeCommandInfo("packages", "list service folders in the monorepo", { relative: { @@ -12,11 +15,6 @@ export const commandInfo = makeCommandInfo("packages", "list service folders in }, }); -import path from "path"; -import { resolveRoot } from "../../../util/resolveProject"; - -import { readdir } from "fs/promises"; - export async function getServiceFolders(root?: string): Promise { root ??= await resolveRoot(); return ( diff --git a/common/tools/dev-tool/src/commands/admin/stage-migrations.ts b/common/tools/dev-tool/src/commands/admin/stage-migrations.ts index 5c7e097ff683..5017e361d060 100644 --- a/common/tools/dev-tool/src/commands/admin/stage-migrations.ts +++ b/common/tools/dev-tool/src/commands/admin/stage-migrations.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { readFile, writeFile } from "fs/promises"; -import path from "path"; +import { readFile, writeFile } from "node:fs/promises"; +import path from "node:path"; import { leafCommand, makeCommandInfo } from "../../framework/command"; import { getServiceFolders } from "./list/service-folders"; diff --git a/common/tools/dev-tool/src/commands/customization/apply-v2.ts b/common/tools/dev-tool/src/commands/customization/apply-v2.ts index 884493b8b569..3dad28f876f5 100644 --- a/common/tools/dev-tool/src/commands/customization/apply-v2.ts +++ b/common/tools/dev-tool/src/commands/customization/apply-v2.ts @@ -6,7 +6,6 @@ import { createPrinter } from "../../util/printer"; import { run } from "../../util/run"; import { leafCommand } from "../../framework/command"; import { makeCommandInfo } from "../../framework/command"; - import path from "node:path"; import fs from "node:fs/promises"; import os from "node:os"; diff --git a/common/tools/dev-tool/src/commands/customization/apply.ts b/common/tools/dev-tool/src/commands/customization/apply.ts index 78e3d0bcc8df..591f18378425 100644 --- a/common/tools/dev-tool/src/commands/customization/apply.ts +++ b/common/tools/dev-tool/src/commands/customization/apply.ts @@ -1,13 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license -import path from "path"; - +import path from "node:path"; import { resolveProject } from "../../util/resolveProject"; import { createPrinter } from "../../util/printer"; import { leafCommand } from "../../framework/command"; import { makeCommandInfo } from "../../framework/command"; - import { customize } from "../../util/customization/customize"; const log = createPrinter("apply-customization"); diff --git a/common/tools/dev-tool/src/commands/migrate.ts b/common/tools/dev-tool/src/commands/migrate.ts index ac2f9ba329e1..319ee6c2cab9 100644 --- a/common/tools/dev-tool/src/commands/migrate.ts +++ b/common/tools/dev-tool/src/commands/migrate.ts @@ -5,7 +5,7 @@ import { METADATA_KEY, ProjectInfo, resolveProject, resolveRoot } from "../util/ import { createPrinter } from "../util/printer"; import { leafCommand } from "../framework/command"; import { makeCommandInfo } from "../framework/command"; -import { cwd } from "process"; +import { cwd } from "node:process"; import { listAppliedMigrations, getMigrationById, diff --git a/common/tools/dev-tool/src/commands/package/resolve.ts b/common/tools/dev-tool/src/commands/package/resolve.ts index 966a0a4f1628..4ff8387caed7 100644 --- a/common/tools/dev-tool/src/commands/package/resolve.ts +++ b/common/tools/dev-tool/src/commands/package/resolve.ts @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license -import path from "path"; - +import path from "node:path"; import { resolveProject } from "../../util/resolveProject"; import { createPrinter } from "../../util/printer"; import { leafCommand } from "../../framework/command"; diff --git a/common/tools/dev-tool/src/commands/run/build-test.ts b/common/tools/dev-tool/src/commands/run/build-test.ts index 1d91bf8a159b..2139943c5c65 100644 --- a/common/tools/dev-tool/src/commands/run/build-test.ts +++ b/common/tools/dev-tool/src/commands/run/build-test.ts @@ -2,7 +2,15 @@ // Licensed under the MIT license. import path from "node:path"; -import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs"; +import { + cpSync, + existsSync, + mkdirSync, + readFileSync, + readdirSync, + statSync, + writeFileSync, +} from "node:fs"; import { leafCommand, makeCommandInfo } from "../../framework/command"; import { createPrinter } from "../../util/printer"; import { resolveProject } from "../../util/resolveProject"; @@ -146,7 +154,7 @@ function copyOverrides(type: string, rootDir: string, filePath: string): void { const fileToReplaceWith = path.join( fileParsed.root, fileParsed.dir, - `${fileParsed.name}-${type}.mts` + `${fileParsed.name}-${type}.mts`, ); if (existsSync(fileToReplace) && existsSync(fileToReplaceWith)) { log.info(`Copying over ${fileToReplaceWith} to ${fileToReplace}`); @@ -156,20 +164,20 @@ function copyOverrides(type: string, rootDir: string, filePath: string): void { rootDir, relativeDir, `${fileParsed.name}-${type}.d.mts`, - `${fileParsed.name}.d.ts` + `${fileParsed.name}.d.ts`, ); overrideFile( rootDir, relativeDir, `${fileParsed.name}-${type}.d.mts.map`, - `${fileParsed.name}.d.ts.map` + `${fileParsed.name}.d.ts.map`, ); overrideFile(rootDir, relativeDir, `${fileParsed.name}-${type}.mjs`, `${fileParsed.name}.js`); overrideFile( rootDir, relativeDir, `${fileParsed.name}-${type}.mjs.map`, - `${fileParsed.name}.js.map` + `${fileParsed.name}.js.map`, ); } } @@ -178,7 +186,7 @@ function overrideFile( rootDir: string, relativeDir: string, sourceFile: string, - destinationFile: string + destinationFile: string, ): void { const sourceFileType = path.join(process.cwd(), rootDir, relativeDir, sourceFile); const destFileType = path.join(process.cwd(), rootDir, relativeDir, destinationFile); @@ -189,7 +197,10 @@ function overrideFile( class OverrideSet { public map: Map; - constructor(public type: "esm" | "commonjs", public name: string) { + constructor( + public type: "esm" | "commonjs", + public name: string, + ) { this.map = new Map(); } diff --git a/common/tools/dev-tool/src/commands/run/bundle.ts b/common/tools/dev-tool/src/commands/run/bundle.ts index fb9c0ba65665..588a70a57e78 100644 --- a/common/tools/dev-tool/src/commands/run/bundle.ts +++ b/common/tools/dev-tool/src/commands/run/bundle.ts @@ -1,18 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import path from "path"; - +import path from "node:path"; import * as rollup from "rollup"; import nodeBuiltins from "builtin-modules"; - import nodeResolve from "@rollup/plugin-node-resolve"; import cjs from "@rollup/plugin-commonjs"; import nodePolyfills from "rollup-plugin-polyfill-node"; import json from "@rollup/plugin-json"; import multiEntry from "@rollup/plugin-multi-entry"; import inject from "@rollup/plugin-inject"; - import { leafCommand, makeCommandInfo } from "../../framework/command"; import { resolveProject, resolveRoot } from "../../util/resolveProject"; import { createPrinter } from "../../util/printer"; diff --git a/common/tools/dev-tool/src/commands/run/check-api.ts b/common/tools/dev-tool/src/commands/run/check-api.ts index 5dbc0970c06c..478924db328d 100644 --- a/common/tools/dev-tool/src/commands/run/check-api.ts +++ b/common/tools/dev-tool/src/commands/run/check-api.ts @@ -1,10 +1,12 @@ -import { leafCommand, makeCommandInfo } from "../../framework/command"; +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { leafCommand, makeCommandInfo } from "../../framework/command"; import tsMin from "@_ts/min"; import tsMax from "@_ts/max"; import { createPrinter } from "../../util/printer"; import { resolveProject } from "../../util/resolveProject"; -import path from "path"; +import path from "node:path"; import semver from "semver"; export const commandInfo = makeCommandInfo( diff --git a/common/tools/dev-tool/src/commands/run/extract-api.ts b/common/tools/dev-tool/src/commands/run/extract-api.ts index af691bb14e1d..24f9c9fbc373 100644 --- a/common/tools/dev-tool/src/commands/run/extract-api.ts +++ b/common/tools/dev-tool/src/commands/run/extract-api.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { leafCommand, makeCommandInfo } from "../../framework/command"; import { Extractor, @@ -8,13 +11,12 @@ import { IConfigDtsRollup, IConfigFile, } from "@microsoft/api-extractor"; - import { createPrinter } from "../../util/printer"; import { resolveProject } from "../../util/resolveProject"; import path from "path"; import { readFile } from "fs-extra"; -import { readdir } from "fs/promises"; -import { createReadStream, createWriteStream } from "fs"; +import { readdir } from "node:fs/promises"; +import { createReadStream, createWriteStream } from "node:fs"; import archiver from "archiver"; export const commandInfo = makeCommandInfo( diff --git a/common/tools/dev-tool/src/commands/run/testNodeJSInput.ts b/common/tools/dev-tool/src/commands/run/testNodeJSInput.ts index 25bb8acc8b65..ad1c698e10c0 100644 --- a/common/tools/dev-tool/src/commands/run/testNodeJSInput.ts +++ b/common/tools/dev-tool/src/commands/run/testNodeJSInput.ts @@ -2,7 +2,6 @@ // Licensed under the MIT license import { leafCommand, makeCommandInfo } from "../../framework/command"; - import concurrently from "concurrently"; import { createPrinter } from "../../util/printer"; import { isModuleProject } from "../../util/resolveProject"; diff --git a/common/tools/dev-tool/src/commands/run/testNodeTsxJS.ts b/common/tools/dev-tool/src/commands/run/testNodeTsxJS.ts index 60707e05ef6e..34ae0de6b57e 100644 --- a/common/tools/dev-tool/src/commands/run/testNodeTsxJS.ts +++ b/common/tools/dev-tool/src/commands/run/testNodeTsxJS.ts @@ -2,7 +2,6 @@ // Licensed under the MIT license import { leafCommand, makeCommandInfo } from "../../framework/command"; - import concurrently from "concurrently"; import { createPrinter } from "../../util/printer"; import { runTestsWithProxyTool } from "../../util/testUtils"; diff --git a/common/tools/dev-tool/src/commands/run/vendored.ts b/common/tools/dev-tool/src/commands/run/vendored.ts index fa92444e8577..2521d2304257 100644 --- a/common/tools/dev-tool/src/commands/run/vendored.ts +++ b/common/tools/dev-tool/src/commands/run/vendored.ts @@ -7,9 +7,8 @@ */ import fs from "fs-extra"; -import path from "path"; -import { spawn } from "child_process"; - +import path from "node:path"; +import { spawn } from "node:child_process"; import { makeCommandInfo, subCommand } from "../../framework/command"; import { CommandOptions } from "../../framework/CommandInfo"; import { CommandModule } from "../../framework/CommandModule"; diff --git a/common/tools/dev-tool/src/commands/samples/checkNodeVersions.ts b/common/tools/dev-tool/src/commands/samples/checkNodeVersions.ts index 3968fd322162..c3a96a174ebe 100644 --- a/common/tools/dev-tool/src/commands/samples/checkNodeVersions.ts +++ b/common/tools/dev-tool/src/commands/samples/checkNodeVersions.ts @@ -2,10 +2,10 @@ // Licensed under the MIT license. import fs from "fs-extra"; -import path from "path"; -import pr from "child_process"; -import os from "os"; -import { URL } from "url"; +import path from "node:path"; +import pr from "node:child_process"; +import os from "node:os"; +import { URL } from "node:url"; import { createPrinter } from "../../util/printer"; import { leafCommand, makeCommandInfo } from "../../framework/command"; diff --git a/common/tools/dev-tool/src/commands/samples/dev.ts b/common/tools/dev-tool/src/commands/samples/dev.ts index af925bba42f3..a89974b81b1f 100644 --- a/common/tools/dev-tool/src/commands/samples/dev.ts +++ b/common/tools/dev-tool/src/commands/samples/dev.ts @@ -2,8 +2,7 @@ // Licensed under the MIT license. import fs from "fs-extra"; -import path from "path"; - +import path from "node:path"; import { resolveProject } from "../../util/resolveProject"; import { createPrinter } from "../../util/printer"; import { leafCommand, makeCommandInfo } from "../../framework/command"; diff --git a/common/tools/dev-tool/src/commands/samples/prep.ts b/common/tools/dev-tool/src/commands/samples/prep.ts index b065ad11305d..7820f16c1d3a 100644 --- a/common/tools/dev-tool/src/commands/samples/prep.ts +++ b/common/tools/dev-tool/src/commands/samples/prep.ts @@ -2,8 +2,7 @@ // Licensed under the MIT license. import fs from "fs-extra"; -import path from "path"; - +import path from "node:path"; import { createPrinter } from "../../util/printer"; import { findMatchingFiles } from "../../util/findMatchingFiles"; import { resolveProject } from "../../util/resolveProject"; diff --git a/common/tools/dev-tool/src/commands/samples/publish.ts b/common/tools/dev-tool/src/commands/samples/publish.ts index aeb781d7dbc5..04c7bd364544 100644 --- a/common/tools/dev-tool/src/commands/samples/publish.ts +++ b/common/tools/dev-tool/src/commands/samples/publish.ts @@ -8,7 +8,7 @@ * that are eventually used to generate a coherent set of sample programs. */ -import path from "path"; +import path from "node:path"; import { leafCommand, makeCommandInfo } from "../../framework/command"; import { createPrinter } from "../../util/printer"; import { resolveProject } from "../../util/resolveProject"; diff --git a/common/tools/dev-tool/src/commands/samples/run.ts b/common/tools/dev-tool/src/commands/samples/run.ts index 5b4fc5521990..8c4d49d6d0c6 100644 --- a/common/tools/dev-tool/src/commands/samples/run.ts +++ b/common/tools/dev-tool/src/commands/samples/run.ts @@ -2,8 +2,7 @@ // Licensed under the MIT license. import fs from "fs-extra"; -import path from "path"; - +import path from "node:path"; import { findMatchingFiles } from "../../util/findMatchingFiles"; import { createPrinter } from "../../util/printer"; import { leafCommand, makeCommandInfo } from "../../framework/command"; diff --git a/common/tools/dev-tool/src/commands/test-proxy/init.ts b/common/tools/dev-tool/src/commands/test-proxy/init.ts index e7215f4920f8..9cc8b984cac3 100644 --- a/common/tools/dev-tool/src/commands/test-proxy/init.ts +++ b/common/tools/dev-tool/src/commands/test-proxy/init.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { cwd } from "process"; +import { cwd } from "node:process"; import { leafCommand, makeCommandInfo } from "../../framework/command"; import { resolveProject } from "../../util/resolveProject"; import { createAssetsJson } from "../../util/testProxyUtils"; diff --git a/common/tools/dev-tool/src/config/rollup.base.config.ts b/common/tools/dev-tool/src/config/rollup.base.config.ts index 830cea7b9b92..d39a84951a0a 100644 --- a/common/tools/dev-tool/src/config/rollup.base.config.ts +++ b/common/tools/dev-tool/src/config/rollup.base.config.ts @@ -8,14 +8,12 @@ import { RollupLog, WarningHandlerWithDefault, } from "rollup"; - import nodeResolve from "@rollup/plugin-node-resolve"; import cjs from "@rollup/plugin-commonjs"; import multiEntry from "@rollup/plugin-multi-entry"; import json from "@rollup/plugin-json"; -import * as path from "path"; +import * as path from "node:path"; import { readFile } from "node:fs/promises"; - import nodeBuiltins from "builtin-modules"; import { createPrinter } from "../util/printer"; diff --git a/common/tools/dev-tool/src/framework/parseOptions.ts b/common/tools/dev-tool/src/framework/parseOptions.ts index ac48f252e7ea..474a8f8d524e 100644 --- a/common/tools/dev-tool/src/framework/parseOptions.ts +++ b/common/tools/dev-tool/src/framework/parseOptions.ts @@ -2,7 +2,6 @@ // Licensed under the MIT license import getArgs from "minimist"; - import { createPrinter } from "../util/printer"; import { CommandOptions, StringOptionDescription, BooleanOptionDescription } from "./CommandInfo"; diff --git a/common/tools/dev-tool/src/migrations/onboard/test-proxy-asset-sync.ts b/common/tools/dev-tool/src/migrations/onboard/test-proxy-asset-sync.ts index 87f25f3ab297..cf2a93531d2d 100644 --- a/common/tools/dev-tool/src/migrations/onboard/test-proxy-asset-sync.ts +++ b/common/tools/dev-tool/src/migrations/onboard/test-proxy-asset-sync.ts @@ -2,10 +2,9 @@ // Licensed under the MIT license. import { readFile, pathExists } from "fs-extra"; -import path from "path"; +import path from "node:path"; import { createMigration } from "../../util/migrations"; import { runMigrationScript } from "../../util/testProxyUtils"; - import * as git from "../../util/git"; import * as pwsh from "../../util/pwsh"; diff --git a/common/tools/dev-tool/src/templates/migration.ts b/common/tools/dev-tool/src/templates/migration.ts index 166a684e94de..84b1cb5c9f88 100644 --- a/common/tools/dev-tool/src/templates/migration.ts +++ b/common/tools/dev-tool/src/templates/migration.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. + /** * Information used to instantiate the migration code template. */ diff --git a/common/tools/dev-tool/src/templates/sampleReadme.md.ts b/common/tools/dev-tool/src/templates/sampleReadme.md.ts index fa91dd4de274..e2aa31e1e139 100644 --- a/common/tools/dev-tool/src/templates/sampleReadme.md.ts +++ b/common/tools/dev-tool/src/templates/sampleReadme.md.ts @@ -1,9 +1,8 @@ // Copyright (c) Microsoft corporation. // Licensed under the MIT license. -import path from "path"; +import path from "node:path"; import YAML from "yaml"; - import { SampleReadmeConfiguration } from "../util/samples/info"; import { format } from "../util/prettier"; @@ -82,8 +81,9 @@ function resourceLinks(info: SampleReadmeConfiguration) { function resources(info: SampleReadmeConfiguration) { const resources = Object.entries(info.requiredResources ?? {}); - const header = `You need [an Azure subscription][freesub] ${resources.length > 0 ? "and the following Azure resources " : "" - }to run these sample programs${resources.length > 0 ? ":\n\n" : "."}`; + const header = `You need [an Azure subscription][freesub] ${ + resources.length > 0 ? "and the following Azure resources " : "" + }to run these sample programs${resources.length > 0 ? ":\n\n" : "."}`; return ( header + resources.map(([name]) => `- [${name}][${resourceNameToLinkSlug(name)}]`).join("\n") @@ -134,8 +134,9 @@ function exampleNodeInvocation(info: SampleReadmeConfiguration) { .map((envVar) => `${envVar}="<${envVar.replace(/_/g, " ").toLowerCase()}>"`) .join(" "); - return `${envVars} node ${info.useTypeScript ? "dist/" : "" - }${firstModule.relativeSourcePath.replace(/\.ts$/, ".js")}`; + return `${envVars} node ${ + info.useTypeScript ? "dist/" : "" + }${firstModule.relativeSourcePath.replace(/\.ts$/, ".js")}`; } /** @@ -165,7 +166,8 @@ export default (info: SampleReadmeConfiguration): Promise => { ${info.customSnippets?.header ?? ""} -These sample programs show how to use the ${language} client libraries for ${info.productName +These sample programs show how to use the ${language} client libraries for ${ + info.productName } in some common scenarios. ${table(info)} @@ -175,17 +177,17 @@ ${table(info)} The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). ${(() => { - if (info.useTypeScript) { - return [ - "Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using:", - "", - fence("bash", "npm install -g typescript"), - "", - ].join("\n"); - } else { - return ""; - } - })()}\ + if (info.useTypeScript) { + return [ + "Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using:", + "", + fence("bash", "npm install -g typescript"), + "", + ].join("\n"); + } else { + return ""; + } +})()}\ ${resources(info)} ${info.customSnippets?.prerequisites ?? ""} @@ -202,28 +204,28 @@ ${step("Install the dependencies using `npm`:")} ${fence("bash", "npm install")} ${(() => { - if (info.useTypeScript) { - return [step("Compile the samples:"), "", fence("bash", "npm run build"), ""].join("\n"); - } else { - return ""; - } - })()} + if (info.useTypeScript) { + return [step("Compile the samples:"), "", fence("bash", "npm run build"), ""].join("\n"); + } else { + return ""; + } +})()} ${step( - "Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically.", - )} + "Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically.", +)} ${step( - "Run whichever samples you like (note that some samples may require additional setup, see the table above):", - )} + "Run whichever samples you like (note that some samples may require additional setup, see the table above):", +)} ${fence( - "bash", - `node ${(() => { - const firstSource = filterModules(info)[0].relativeSourcePath; - const filePath = info.useTypeScript ? "dist/" : ""; - return filePath + firstSource.replace(/\.ts$/, ".js"); - })()}`, - )} + "bash", + `node ${(() => { + const firstSource = filterModules(info)[0].relativeSourcePath; + const filePath = info.useTypeScript ? "dist/" : ""; + return filePath + firstSource.replace(/\.ts$/, ".js"); + })()}`, +)} Alternatively, run a single sample with the correct environment variables set (setting up the \`.env\` file is not required if you do this), for example (cross-platform): diff --git a/common/tools/dev-tool/src/util/customization/customize.ts b/common/tools/dev-tool/src/util/customization/customize.ts index a3481bd66e0a..c9c744af6ad6 100644 --- a/common/tools/dev-tool/src/util/customization/customize.ts +++ b/common/tools/dev-tool/src/util/customization/customize.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license -import { copyFile, stat, readFile, writeFile, readdir } from "fs/promises"; +import { copyFile, stat, readFile, writeFile, readdir } from "node:fs/promises"; import { ensureDir, copy } from "fs-extra"; import path from "../pathUtil"; import { @@ -23,7 +23,6 @@ import { augmentTypeAliases } from "./aliases"; import { setCustomizationState, resetCustomizationState } from "./state"; import { getNewCustomFiles } from "./helpers/files"; import { augmentImports } from "./imports"; - import { format } from "../prettier"; import { augmentExports } from "./exports"; diff --git a/common/tools/dev-tool/src/util/fileTree.ts b/common/tools/dev-tool/src/util/fileTree.ts index c07297e45def..c414e02795ab 100644 --- a/common/tools/dev-tool/src/util/fileTree.ts +++ b/common/tools/dev-tool/src/util/fileTree.ts @@ -2,9 +2,8 @@ // Licensed under the MIT license. import fs from "fs-extra"; -import os from "os"; -import path from "path"; - +import os from "node:os"; +import path from "node:path"; import { createPrinter } from "./printer"; import * as git from "./git"; diff --git a/common/tools/dev-tool/src/util/findMatchingFiles.ts b/common/tools/dev-tool/src/util/findMatchingFiles.ts index ce1efcbcc4f6..bb8fec987ed9 100644 --- a/common/tools/dev-tool/src/util/findMatchingFiles.ts +++ b/common/tools/dev-tool/src/util/findMatchingFiles.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license import fs from "fs-extra"; -import path from "path"; +import path from "node:path"; import { createPrinter } from "./printer"; import { shouldSkip } from "./samples/configuration"; diff --git a/common/tools/dev-tool/src/util/findSamplesDir.ts b/common/tools/dev-tool/src/util/findSamplesDir.ts index 3afb7b06e85f..b20fa393f9de 100644 --- a/common/tools/dev-tool/src/util/findSamplesDir.ts +++ b/common/tools/dev-tool/src/util/findSamplesDir.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license import fs from "fs-extra"; -import path from "path"; +import path from "node:path"; export function findSamplesRelativeDir(samplesDir: string): string { const dirs = []; diff --git a/common/tools/dev-tool/src/util/git.ts b/common/tools/dev-tool/src/util/git.ts index 28d91cc9c55c..64ccf2550e2c 100644 --- a/common/tools/dev-tool/src/util/git.ts +++ b/common/tools/dev-tool/src/util/git.ts @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { spawn } from "child_process"; -import { tmpdir } from "os"; - -import path from "path"; +import { spawn } from "node:child_process"; +import { tmpdir } from "node:os"; +import path from "node:path"; /** * Uses the git command line to ask whether a path has any tracked, unstaged changes (if they would appear in a git diff --git a/common/tools/dev-tool/src/util/migrations.ts b/common/tools/dev-tool/src/util/migrations.ts index 18928001a8e6..ef6fa0086cb0 100644 --- a/common/tools/dev-tool/src/util/migrations.ts +++ b/common/tools/dev-tool/src/util/migrations.ts @@ -2,8 +2,8 @@ // Licensed under the MIT license. import { mkdirp, readFile, rm, stat, Stats, writeFile } from "fs-extra"; -import { userInfo } from "os"; -import path from "path"; +import { userInfo } from "node:os"; +import path from "node:path"; import { panic } from "./assert"; import { findMatchingFiles } from "./findMatchingFiles"; import { createPrinter, Printer } from "./printer"; diff --git a/common/tools/dev-tool/src/util/pathUtil.ts b/common/tools/dev-tool/src/util/pathUtil.ts index 86c6fcaf0f3b..d0739fdd32ca 100644 --- a/common/tools/dev-tool/src/util/pathUtil.ts +++ b/common/tools/dev-tool/src/util/pathUtil.ts @@ -1,4 +1,7 @@ -import path from "path"; +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import path from "node:path"; function toPosixWrapper any>(f: T): T { const wrapped = (...args: Parameters): ReturnType => { diff --git a/common/tools/dev-tool/src/util/prettier.ts b/common/tools/dev-tool/src/util/prettier.ts index 52ad480b5f6c..b9ecb351141e 100644 --- a/common/tools/dev-tool/src/util/prettier.ts +++ b/common/tools/dev-tool/src/util/prettier.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import * as prettier from "prettier"; import prettierOptions from "../../../eslint-plugin-azure-sdk/prettier.json"; diff --git a/common/tools/dev-tool/src/util/printer.ts b/common/tools/dev-tool/src/util/printer.ts index 441b378ff67d..c0804f9be8fa 100644 --- a/common/tools/dev-tool/src/util/printer.ts +++ b/common/tools/dev-tool/src/util/printer.ts @@ -4,7 +4,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import chalk from "chalk"; -import path from "path"; +import path from "node:path"; const printModes = ["info", "warn", "error", "success", "debug"] as const; diff --git a/common/tools/dev-tool/src/util/resolveProject.ts b/common/tools/dev-tool/src/util/resolveProject.ts index ac2b03410350..be9323461dcd 100644 --- a/common/tools/dev-tool/src/util/resolveProject.ts +++ b/common/tools/dev-tool/src/util/resolveProject.ts @@ -2,8 +2,7 @@ // Licensed under the MIT license. import fs from "fs-extra"; -import path from "path"; - +import path from "node:path"; import { createPrinter } from "./printer"; import { SampleConfiguration } from "./samples/configuration"; diff --git a/common/tools/dev-tool/src/util/run.ts b/common/tools/dev-tool/src/util/run.ts index 4647b1746ca0..7af269b12358 100644 --- a/common/tools/dev-tool/src/util/run.ts +++ b/common/tools/dev-tool/src/util/run.ts @@ -1,4 +1,7 @@ -import { SpawnOptions, spawn } from "child_process"; +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { SpawnOptions, spawn } from "node:child_process"; export interface RunOptions extends SpawnOptions { captureOutput?: boolean; diff --git a/common/tools/dev-tool/src/util/samples/convert.ts b/common/tools/dev-tool/src/util/samples/convert.ts index c0443b04fa8c..8798061e4074 100644 --- a/common/tools/dev-tool/src/util/samples/convert.ts +++ b/common/tools/dev-tool/src/util/samples/convert.ts @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { EOL } from "os"; - +import { EOL } from "node:os"; import ts from "typescript"; - import { createPrinter } from "../printer"; import { format } from "../prettier"; diff --git a/common/tools/dev-tool/src/util/samples/generation.ts b/common/tools/dev-tool/src/util/samples/generation.ts index 38e610877b76..caba85078f81 100644 --- a/common/tools/dev-tool/src/util/samples/generation.ts +++ b/common/tools/dev-tool/src/util/samples/generation.ts @@ -1,5 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import fs from "fs-extra"; -import path from "path"; +import path from "node:path"; import { copy, dir, file, FileTreeFactory, lazy, safeClean, temp } from "../fileTree"; import { findMatchingFiles } from "../findMatchingFiles"; import { createPrinter } from "../printer"; @@ -17,7 +20,6 @@ import { SampleGenerationInfo, } from "./info"; import { processSources } from "./processor"; - import devToolPackageJson from "../../../package.json"; import instantiateSampleReadme from "../../templates/sampleReadme.md"; import { resolveModule } from "./transforms"; diff --git a/common/tools/dev-tool/src/util/samples/processor.ts b/common/tools/dev-tool/src/util/samples/processor.ts index 977fbb807eb0..b5c286eea950 100644 --- a/common/tools/dev-tool/src/util/samples/processor.ts +++ b/common/tools/dev-tool/src/util/samples/processor.ts @@ -2,8 +2,8 @@ // Licensed under the MIT license. import fs from "fs-extra"; -import path from "path"; -import * as ts from "typescript"; +import path from "node:path"; +import ts from "typescript"; import { convert } from "./convert"; import { createPrinter } from "../printer"; import { createAccumulator } from "../typescript/accumulator"; diff --git a/common/tools/dev-tool/src/util/samples/syntax.ts b/common/tools/dev-tool/src/util/samples/syntax.ts index 88f2585a5b94..919e03e1d383 100644 --- a/common/tools/dev-tool/src/util/samples/syntax.ts +++ b/common/tools/dev-tool/src/util/samples/syntax.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import * as ts from "typescript"; +import ts from "typescript"; /** * Tests for syntax compatibility. diff --git a/common/tools/dev-tool/src/util/testProxyUtils.ts b/common/tools/dev-tool/src/util/testProxyUtils.ts index 5767f6536b89..82d0cbb41384 100644 --- a/common/tools/dev-tool/src/util/testProxyUtils.ts +++ b/common/tools/dev-tool/src/util/testProxyUtils.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { ChildProcess, exec, spawn, SpawnOptions } from "child_process"; +import { ChildProcess, exec, spawn, SpawnOptions } from "node:child_process"; import { createPrinter } from "./printer"; import { ProjectInfo, resolveProject, resolveRoot } from "./resolveProject"; import fs from "fs-extra"; -import path from "path"; +import path from "node:path"; import decompress from "decompress"; import envPaths from "env-paths"; -import { promisify } from "util"; +import { promisify } from "node:util"; const log = createPrinter("test-proxy"); const downloadLocation = path.join(envPaths("azsdk-dev-tool").cache, "test-proxy"); diff --git a/common/tools/dev-tool/src/util/testUtils.ts b/common/tools/dev-tool/src/util/testUtils.ts index a53b1f000b27..234835ab3dab 100644 --- a/common/tools/dev-tool/src/util/testUtils.ts +++ b/common/tools/dev-tool/src/util/testUtils.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { isProxyToolActive, startTestProxy, TestProxy } from "./testProxyUtils"; import concurrently, { Command as ConcurrentlyCommand } from "concurrently"; import { createPrinter } from "./printer"; diff --git a/common/tools/dev-tool/src/util/typescript/diagnostic.ts b/common/tools/dev-tool/src/util/typescript/diagnostic.ts index dfaad0cd2fe4..03c886dc766e 100644 --- a/common/tools/dev-tool/src/util/typescript/diagnostic.ts +++ b/common/tools/dev-tool/src/util/typescript/diagnostic.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import ts from "typescript"; -import { EOL } from "os"; +import { EOL } from "node:os"; /** * The type of the emitter function. diff --git a/common/tools/dev-tool/test/argParsing.spec.ts b/common/tools/dev-tool/test/argParsing.spec.ts index ae960fc038d7..01f4ec93e0d3 100644 --- a/common/tools/dev-tool/test/argParsing.spec.ts +++ b/common/tools/dev-tool/test/argParsing.spec.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { assert } from "chai"; +import { describe, it, assert, beforeAll } from "vitest"; import { spawn } from "child_process"; import { StrictAllowMultiple } from "../src/framework/command"; import { CommandOptions } from "../src/framework/CommandInfo"; @@ -49,7 +49,7 @@ function shellSplit(args: string): Promise { } describe("argument parsing", function () { - before(silenceLogger); + beforeAll(silenceLogger); it("simple option", async () => { const parsed = parseOptions( diff --git a/common/tools/dev-tool/test/customization/aliases.spec.ts b/common/tools/dev-tool/test/customization/aliases.spec.ts index cc1583e314d8..3ec47e8b960d 100644 --- a/common/tools/dev-tool/test/customization/aliases.spec.ts +++ b/common/tools/dev-tool/test/customization/aliases.spec.ts @@ -1,6 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { describe, it, assert, beforeEach } from "vitest"; import { Project, SourceFile, TypeAliasDeclaration } from "ts-morph"; import { augmentTypeAliases } from "../../src/util/customization/aliases"; -import { expect } from "chai"; describe("Customization", () => { let project: Project; @@ -25,7 +28,7 @@ describe("Customization", () => { augmentTypeAliases(originalAliases, customAliases, originalFile); - expect(originalFile.getTypeAlias("CustomAlias")).not.to.be.undefined; + assert.isDefined(originalFile.getTypeAlias("CustomAlias")); }); it("should replace existing aliases with custom aliases", () => { @@ -43,7 +46,8 @@ describe("Customization", () => { augmentTypeAliases(originalAliases, customAliases, originalFile); - expect(originalFile.getTypeAlias("OriginalAlias")?.getText()).to.equal( + assert.equal( + originalFile.getTypeAlias("OriginalAlias")?.getText(), "type OriginalAlias = number;", ); }); diff --git a/common/tools/dev-tool/test/customization/annotations.spec.ts b/common/tools/dev-tool/test/customization/annotations.spec.ts index ae67a8e44358..c5808be8c6d0 100644 --- a/common/tools/dev-tool/test/customization/annotations.spec.ts +++ b/common/tools/dev-tool/test/customization/annotations.spec.ts @@ -1,6 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { describe, it, assert, beforeEach } from "vitest"; import { Project, SourceFile } from "ts-morph"; import { getAnnotation } from "../../src/util/customization/helpers/annotations"; -import { expect } from "chai"; describe("Annotations", () => { let project: Project; @@ -21,7 +24,7 @@ describe("Annotations", () => { }); const annotation = getAnnotation(functionDeclaration); - expect(annotation).to.deep.equal({ type: "remove", param: undefined }); + assert.deepEqual(annotation, { type: "remove", param: undefined }); }); it("should find it in Properties", () => { @@ -38,7 +41,7 @@ describe("Annotations", () => { const propertyDeclaration = interfaceDeclaration.getProperty("myProperty")!; const annotation = getAnnotation(propertyDeclaration); - expect(annotation).to.deep.equal({ type: "remove", param: undefined }); + assert.deepEqual(annotation, { type: "remove", param: undefined }); }); it("should find it in CallSignatures", () => { @@ -54,7 +57,7 @@ describe("Annotations", () => { const callSignatureDeclaration = interfaceDeclaration.getCallSignatures()[0]; const annotation = getAnnotation(callSignatureDeclaration); - expect(annotation).to.deep.equal({ type: "remove", param: undefined }); + assert.deepEqual(annotation, { type: "remove", param: undefined }); }); }); @@ -67,7 +70,7 @@ describe("Annotations", () => { }); const annotation = getAnnotation(functionDeclaration); - expect(annotation).to.deep.equal({ type: "rename", param: "myNewFunction" }); + assert.deepEqual(annotation, { type: "rename", param: "myNewFunction" }); }); it("should find it in Properties", () => { @@ -84,7 +87,7 @@ describe("Annotations", () => { const propertyDeclaration = interfaceDeclaration.getProperty("myProperty")!; const annotation = getAnnotation(propertyDeclaration); - expect(annotation).to.deep.equal({ type: "rename", param: "myNewProperty" }); + assert.deepEqual(annotation, { type: "rename", param: "myNewProperty" }); }); }); }); @@ -97,7 +100,7 @@ describe("Annotations", () => { }); const annotation = getAnnotation(functionDeclaration); - expect(annotation).to.be.undefined; + assert.isUndefined(annotation); }); it("should not find any in Properties", () => { @@ -113,7 +116,7 @@ describe("Annotations", () => { const propertyDeclaration = interfaceDeclaration.getProperty("myProperty")!; const annotation = getAnnotation(propertyDeclaration); - expect(annotation).to.be.undefined; + assert.isUndefined(annotation); }); it("should not find any in CallSignatures", () => { @@ -128,7 +131,7 @@ describe("Annotations", () => { const callSignatureDeclaration = interfaceDeclaration.getCallSignatures()[0]; const annotation = getAnnotation(callSignatureDeclaration); - expect(annotation).to.be.undefined; + assert.isUndefined(annotation); }); }); }); diff --git a/common/tools/dev-tool/test/customization/classes.spec.ts b/common/tools/dev-tool/test/customization/classes.spec.ts index f86c2a1bf950..30aae9c76856 100644 --- a/common/tools/dev-tool/test/customization/classes.spec.ts +++ b/common/tools/dev-tool/test/customization/classes.spec.ts @@ -1,3 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { describe, it, assert, beforeEach, afterEach } from "vitest"; import { Project, SourceFile, @@ -11,7 +15,6 @@ import { augmentConstructor, augmentMethod, } from "../../src/util/customization/classes"; -import { expect } from "chai"; describe("Classes", () => { let project: Project; @@ -61,16 +64,17 @@ class MyClass {} it("should add a new class to the source file", () => { augmentClass(undefined, customClass, originalFile); - expect(originalFile.getClass("MyClass")).to.not.be.undefined; + assert.isDefined(originalFile.getClass("MyClass")); }); it("should add properties only present in the custom class", () => { originalClass = originalFile.addClass({ name: "MyClass" }); customClass.addProperty({ name: "myProperty", type: "string" }); augmentClass(originalClass, customClass, originalFile); - expect( + assert.equal( originalFile.getClass("MyClass")?.getProperty("myProperty")?.getType().getText(), - ).to.equal("string"); + "string", + ); }); it("should not add the class augmentation property", () => { @@ -78,19 +82,21 @@ class MyClass {} customClass.addProperty({ name: "myProperty", type: "string" }); customClass.addProperty({ name: AUGMENT_CLASS_TOKEN, type: "string" }); augmentClass(originalClass, customClass, originalFile); - expect(originalFile.getClass("MyClass")?.getProperty(AUGMENT_CLASS_TOKEN)).to.be.undefined; - expect( + assert.isUndefined(originalFile.getClass("MyClass")?.getProperty(AUGMENT_CLASS_TOKEN)); + assert.equal( originalFile.getClass("MyClass")?.getProperty("myProperty")?.getType().getText(), - ).to.equal("string"); + "string", + ); }); it("should replace the original property with the custom property", () => { originalClass = originalFile.addClass({ name: "MyClass" }); originalClass.addProperty({ name: "myProperty", type: "number" }); customClass.addProperty({ name: "myProperty", type: "string" }); augmentClass(originalClass, customClass, originalFile); - expect( + assert.equal( originalFile.getClass("MyClass")?.getProperty("myProperty")?.getType().getText(), - ).to.equal("string"); + "string", + ); }); }); @@ -117,7 +123,7 @@ class MyClass {} }); augmentMethod(originalMethod, customMethod, originalClass!); - expect(originalFile.getClass("MyClass")?.getMethod("myMethod")).to.not.be.undefined; + assert.isDefined(originalFile.getClass("MyClass")?.getMethod("myMethod")); }); it("should augment an existing method in the original class", () => { @@ -133,9 +139,10 @@ class MyClass {} augmentMethod(originalMethod, customMethod, originalClass!); - expect( + assert.equal( originalFile.getClass("MyClass")?.getMethod("myMethod")?.getReturnType().getText(), - ).to.equal("number"); + "number", + ); }); it("should replace an existing method in the original class", () => { @@ -151,9 +158,10 @@ class MyClass {} augmentMethod(originalMethod, customMethod, originalClass!); - expect( + assert.equal( originalFile.getClass("MyClass")?.getMethod("myMethod")?.getReturnType().getText(), - ).to.equal("number"); + "number", + ); }); it("should augment existing method with the original one", () => { @@ -195,16 +203,16 @@ class MyClass {} ?.getJsDocs() ?.map((x) => x.getDescription()); - expect(methodBody).to.contain("return originalNumber;"); - expect(methodBody).to.not.contain("return 1;"); + assert.include(methodBody, "return originalNumber;"); + assert.notInclude(methodBody, "return 1;"); - expect(methodDocs).to.have.lengthOf(1); - expect(methodDocs?.[0]).to.equal("Customized docs"); + assert.lengthOf(methodDocs!, 1); + assert.equal(methodDocs?.[0], "Customized docs"); - expect(privateMethodBody).to.not.contain("return originalNumber;"); - expect(privateMethodBody).to.contain("return 1;"); + assert.notInclude(privateMethodBody, "return originalNumber;"); + assert.include(privateMethodBody, "return 1;"); - expect(originalFile.getClass("MyClass")?.getProperty(AUGMENT_CLASS_TOKEN)).to.be.undefined; + assert.isUndefined(originalFile.getClass("MyClass")?.getProperty(AUGMENT_CLASS_TOKEN)); }); }); @@ -229,7 +237,7 @@ class MyClass {} }); augmentConstructor(customConstructor, originalClass!); - expect(originalFile.getClass("MyClass")?.getConstructors().length).to.equal(1); + assert.lengthOf(originalFile.getClass("MyClass")?.getConstructors()!, 1); }); it("should replace the original constructor with the custom constructor", () => { @@ -241,11 +249,11 @@ class MyClass {} }); augmentConstructor(customConstructor, originalClass!); - expect(originalFile.getClass("MyClass")?.getConstructors().length).to.equal(1); - expect(originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("foo")).to.not.be - .undefined; - expect(originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("bar")).to.be - .undefined; + assert.lengthOf(originalFile.getClass("MyClass")?.getConstructors()!, 1); + assert.isDefined(originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("foo")); + assert.isUndefined( + originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("bar"), + ); }); it("should augment constructor with original constructor", () => { @@ -277,24 +285,32 @@ class MyClass {} augmentConstructor(customConstructor, originalClass!); - expect(originalFile.getClass("MyClass")?.getConstructors().length).to.equal(1); - expect(originalFile.getClass("MyClass")?.getConstructors()[0].getJsDocs().length).to.equal(1); - expect( + assert.lengthOf(originalFile.getClass("MyClass")?.getConstructors()!, 1); + assert.equal(originalFile.getClass("MyClass")?.getConstructors()[0].getJsDocs().length, 1); + assert.equal( originalFile.getClass("MyClass")?.getConstructors()[0].getJsDocs()[0].getDescription(), - ).to.equal("Customized docs"); - expect(originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("endpoint")).to.not - .be.undefined; - expect(originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("baseUrl")).to.be; - expect(originalFile.getClass("MyClass")?.getConstructors()[0].getText()).to.include( + "Customized docs", + ); + assert.isDefined( + originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("endpoint"), + ); + assert.isUndefined( + originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("baseUrl"), + ); + assert.include( + originalFile.getClass("MyClass")?.getConstructors()[0].getText(), "console.log('custom');", ); - expect(originalFile.getClass("MyClass")?.getConstructors()[0].getText()).to.include( + assert.include( + originalFile.getClass("MyClass")?.getConstructors()[0].getText(), "console.log('original');", ); - expect(originalFile.getClass("MyClass")?.getConstructors()[0].getText()).to.not.include( + assert.notInclude( + originalFile.getClass("MyClass")?.getConstructors()[0].getText(), "// @azsdk-constructor-end", ); - expect(originalFile.getClass("MyClass")?.getConstructors()[0].getText()).to.include( + assert.include( + originalFile.getClass("MyClass")?.getConstructors()[0].getText(), "console.log('finish custom');", ); }); diff --git a/common/tools/dev-tool/test/customization/exports.spec.ts b/common/tools/dev-tool/test/customization/exports.spec.ts index b0509cc3ce31..6f104b9804e4 100644 --- a/common/tools/dev-tool/test/customization/exports.spec.ts +++ b/common/tools/dev-tool/test/customization/exports.spec.ts @@ -1,6 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { describe, it, assert, beforeEach } from "vitest"; import { Project, SourceFile } from "ts-morph"; import { augmentExports } from "../../src/util/customization/exports"; -import { expect } from "chai"; describe("Exports", () => { let project: Project; @@ -20,14 +23,14 @@ describe("Exports", () => { it("should add custom exports to the original file", () => { augmentExports(customFile, originalFile); - expect(originalFile.getExportDeclarations()).to.have.lengthOf(1); + assert.equal(originalFile.getExportDeclarations().length, 1); const exportDeclaration = originalFile.getExportDeclarations()[0]; - expect(exportDeclaration.getModuleSpecifier()?.getLiteralValue()).to.equal("./module"); + assert.equal(exportDeclaration.getModuleSpecifier()?.getLiteralValue(), "./module"); const namedExports = exportDeclaration.getNamedExports(); - expect(namedExports).to.have.lengthOf(1); - expect(namedExports[0].getName()).to.equal("Foo"); + assert.lengthOf(namedExports, 1); + assert.equal(namedExports[0].getName(), "Foo"); }); it("should add named exports to the existing module export if it exists", () => { @@ -38,14 +41,14 @@ describe("Exports", () => { augmentExports(customFile, originalFile); - expect(originalFile.getExportDeclarations()).to.have.lengthOf(1); + assert.equal(originalFile.getExportDeclarations().length, 1); const exportDeclaration = originalFile.getExportDeclarations()[0]; - expect(exportDeclaration.getModuleSpecifier()?.getLiteralValue()).to.equal("./module"); + assert.equal(exportDeclaration.getModuleSpecifier()?.getLiteralValue(), "./module"); const namedExports = exportDeclaration.getNamedExports(); - expect(namedExports).to.have.lengthOf(2); - expect(namedExports.map((e) => e.getName())).contains("Foo"); - expect(namedExports.map((e) => e.getName())).contains("Bar"); + assert.lengthOf(namedExports, 2); + const namedExportNames = namedExports.map((e) => e.getName()); + assert.includeMembers(namedExportNames, ["Foo", "Bar"]); }); }); diff --git a/common/tools/dev-tool/test/customization/functions.spec.ts b/common/tools/dev-tool/test/customization/functions.spec.ts index 50af34464fc0..9a0488aa363e 100644 --- a/common/tools/dev-tool/test/customization/functions.spec.ts +++ b/common/tools/dev-tool/test/customization/functions.spec.ts @@ -1,6 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { describe, it, assert, beforeEach } from "vitest"; import { Project, SourceFile, FunctionDeclaration } from "ts-morph"; import { augmentFunction } from "../../src/util/customization/functions"; -import { expect } from "chai"; describe("Functions", () => { let project: Project; @@ -23,7 +26,7 @@ describe("Functions", () => { it("should add custom functions to the original file", () => { augmentFunction(customFunction, originalFunction, originalFile); - expect(originalFile.getFunction("myFunction")).not.to.be.undefined; + assert.isDefined(originalFile.getFunction("myFunction")); }); it("should replace existing functions with custom functions", () => { @@ -34,9 +37,10 @@ describe("Functions", () => { augmentFunction(customFunction, originalFunction, originalFile); - expect( + assert.equal( originalFile.getFunction("myFunction")?.getParameter("param")?.getType().getText(), - ).to.equal("string"); + "string", + ); }); it("should convert existing functions to private functions", () => { @@ -49,8 +53,8 @@ describe("Functions", () => { augmentFunction(customFunction, originalFunction, originalFile); - expect(originalFile.getFunction("myFunction")).to.not.be.undefined; - expect(originalFile.getFunction("_myFunction")).to.not.be.undefined; - expect(originalFile.getFunction("myFunction")?.getText()).to.include("_myFunction"); + assert.isDefined(originalFile.getFunction("myFunction")); + assert.isDefined(originalFile.getFunction("_myFunction")); + assert.include(originalFile.getFunction("myFunction")?.getText(), "_myFunction"); }); }); diff --git a/common/tools/dev-tool/test/customization/imports.spec.ts b/common/tools/dev-tool/test/customization/imports.spec.ts index 09790fcd2fe5..a78e47bd3753 100644 --- a/common/tools/dev-tool/test/customization/imports.spec.ts +++ b/common/tools/dev-tool/test/customization/imports.spec.ts @@ -1,6 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { describe, it, assert, beforeEach, afterEach } from "vitest"; import { ImportDeclaration, Project } from "ts-morph"; import { augmentImports } from "../../src/util/customization/imports"; -import { expect } from "chai"; import { resetCustomizationState, setCustomizationState } from "../../src/util/customization/state"; describe("Imports", () => { @@ -27,7 +30,7 @@ describe("Imports", () => { augmentImports(imports, customFile.getImportDeclarations(), originalFile); const augmentedImports = originalFile.getImportDeclarations(); - expect(augmentedImports).to.have.lengthOf(0); + assert.equal(augmentedImports.length, 0); }); it("should remove self imports on Windows", () => { @@ -49,7 +52,7 @@ describe("Imports", () => { augmentImports(imports, customFile.getImportDeclarations(), originalFile); const augmentedImports = originalFile.getImportDeclarations(); - expect(augmentedImports).to.have.lengthOf(0); + assert.equal(augmentedImports.length, 0); }); it("should rewrite relative imports to the source directory", () => { @@ -75,11 +78,11 @@ describe("Imports", () => { resetCustomizationState(); const augmentedImports = originalFile.getImportDeclarations(); - expect(augmentedImports).to.have.lengthOf(2); + assert.lengthOf(augmentedImports, 2); const rewrittenImportSpecifier = augmentedImports[0].getModuleSpecifierValue(); - expect(rewrittenImportSpecifier).to.equal("./anotherFile.js"); + assert.equal(rewrittenImportSpecifier, "./anotherFile.js"); const rewrittenImportSpecifier2 = augmentedImports[1].getModuleSpecifierValue(); - expect(rewrittenImportSpecifier2).to.equal("../rest/file.js"); + assert.equal(rewrittenImportSpecifier2, "../rest/file.js"); }); it("rewrite relative imports to the source directory on Windows", () => { @@ -106,11 +109,11 @@ describe("Imports", () => { resetCustomizationState(); const augmentedImports = originalFile.getImportDeclarations(); - expect(augmentedImports).to.have.lengthOf(2); + assert.lengthOf(augmentedImports, 2); const rewrittenImportSpecifier = augmentedImports[0].getModuleSpecifierValue(); - expect(rewrittenImportSpecifier).to.equal("./anotherFile.js"); + assert.equal(rewrittenImportSpecifier, "./anotherFile.js"); const rewrittenImportSpecifier2 = augmentedImports[1].getModuleSpecifierValue(); - expect(rewrittenImportSpecifier2).to.equal("../rest/file.js"); + assert.equal(rewrittenImportSpecifier2, "../rest/file.js"); }); it("should rewrite relative imports to the source directory when nested", () => { @@ -133,9 +136,9 @@ describe("Imports", () => { resetCustomizationState(); const augmentedImports = originalFile.getImportDeclarations(); - expect(augmentedImports).to.have.lengthOf(1); + assert.lengthOf(augmentedImports, 1); const rewrittenImportSpecifier = augmentedImports[0].getModuleSpecifierValue(); - expect(rewrittenImportSpecifier).to.equal("../anotherFile.js"); + assert.equal(rewrittenImportSpecifier, "../anotherFile.js"); }); it("should rewrite relative imports to new files from customization", () => { @@ -158,8 +161,8 @@ describe("Imports", () => { resetCustomizationState(); const augmentedImports = originalFile.getImportDeclarations(); - expect(augmentedImports).to.have.lengthOf(1); + assert.lengthOf(augmentedImports, 1); const rewrittenImportSpecifier = augmentedImports[0].getModuleSpecifierValue(); - expect(rewrittenImportSpecifier).to.equal("../anotherFile.js"); + assert.equal(rewrittenImportSpecifier, "../anotherFile.js"); }); }); diff --git a/common/tools/dev-tool/test/customization/interfaces.spec.ts b/common/tools/dev-tool/test/customization/interfaces.spec.ts index 7573f616f681..bcc208f86b25 100644 --- a/common/tools/dev-tool/test/customization/interfaces.spec.ts +++ b/common/tools/dev-tool/test/customization/interfaces.spec.ts @@ -1,5 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { describe, it, assert, beforeEach } from "vitest"; import { Project, SourceFile, InterfaceDeclaration } from "ts-morph"; -import { expect } from "chai"; import { augmentInterface, augmentInterfaces } from "../../src/util/customization/interfaces"; import { getOriginalDeclarationsMap } from "../../src/util/customization/customize"; @@ -24,7 +27,7 @@ describe("Interfaces", () => { it("should add custom interface to the original file", () => { augmentInterface(customInterface, originalInterface, originalFile); - expect(originalFile.getInterface("myInterface")).not.to.be.undefined; + assert.isDefined(originalFile.getInterface("myInterface")); }); it("should replace existing properties with custom properties", () => { @@ -35,17 +38,19 @@ describe("Interfaces", () => { augmentInterface(customInterface, originalInterface, originalFile); - expect(originalFile.getInterface("myInterface")).not.to.be.undefined; - expect(originalFile.getInterface("myInterface")?.getProperties()).to.have.lengthOf(2); - expect(originalFile.getInterface("myInterface")?.getProperty("foo")).to.not.be.undefined; - expect( + assert.isDefined(originalFile.getInterface("myInterface")); + assert.lengthOf(originalFile.getInterface("myInterface")?.getProperties()!, 2); + assert.isDefined(originalFile.getInterface("myInterface")?.getProperty("foo")); + assert.equal( originalFile.getInterface("myInterface")?.getProperty("foo")?.getType().getText(), - ).to.equal("string"); + "string", + ); - expect(originalFile.getInterface("myInterface")?.getProperty("bar")).to.not.be.undefined; - expect( + assert.isDefined(originalFile.getInterface("myInterface")?.getProperty("bar")); + assert.equal( originalFile.getInterface("myInterface")?.getProperty("bar")?.getType().getText(), - ).to.equal("number"); + "number", + ); }); it("should remove property marked with @azsdk-remove", () => { @@ -61,19 +66,21 @@ describe("Interfaces", () => { augmentInterface(customInterface, originalInterface, originalFile); - expect(originalFile.getInterface("myInterface")).not.to.be.undefined; - expect(originalFile.getInterface("myInterface")?.getProperties()).to.have.lengthOf(2); - expect(originalFile.getInterface("myInterface")?.getProperty("foo")).to.not.be.undefined; - expect(originalFile.getInterface("myInterface")?.getProperty("baz")).to.not.be.undefined; + assert.isDefined(originalFile.getInterface("myInterface")); + assert.lengthOf(originalFile.getInterface("myInterface")?.getProperties()!, 2); + assert.isDefined(originalFile.getInterface("myInterface")?.getProperty("foo")); + assert.isDefined(originalFile.getInterface("myInterface")?.getProperty("baz")); - expect(originalFile.getInterface("myInterface")?.getProperty("bar")).to.be.undefined; - expect( + assert.isUndefined(originalFile.getInterface("myInterface")?.getProperty("bar")); + assert.equal( originalFile.getInterface("myInterface")?.getProperty("foo")?.getType().getText(), - ).to.equal("string"); + "string", + ); - expect( + assert.equal( originalFile.getInterface("myInterface")?.getProperty("baz")?.getType().getText(), - ).to.equal("boolean"); + "boolean", + ); }); it("should rename an interface marked with @azsdk-rename", () => { @@ -94,9 +101,10 @@ describe("Interfaces", () => { augmentInterfaces(originalMap.interfaces, customFile.getInterfaces(), originalFile); - expect(originalFile.getInterface("Dog")).to.be.undefined; - expect(originalFile.getInterface("Pet")).not.to.be.undefined; - expect(originalFile.getInterface("Human")?.getProperty("pets")?.getType().getText()).to.equal( + assert.isUndefined(originalFile.getInterface("Dog")); + assert.isDefined(originalFile.getInterface("Pet")); + assert.equal( + originalFile.getInterface("Human")?.getProperty("pets")?.getType().getText(), "Pet[]", ); }); diff --git a/common/tools/dev-tool/test/framework.spec.ts b/common/tools/dev-tool/test/framework.spec.ts index 879567a55184..52652bce945a 100644 --- a/common/tools/dev-tool/test/framework.spec.ts +++ b/common/tools/dev-tool/test/framework.spec.ts @@ -1,11 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { assert } from "chai"; - +import { describe, it, assert, beforeAll } from "vitest"; import { parseOptions } from "../src/framework/parseOptions"; import { makeCommandInfo, subCommand, leafCommand } from "../src/framework/command"; - import { silenceLogger } from "./util"; const simpleCommandInfo = makeCommandInfo("simple", "a simple command", { @@ -24,7 +22,7 @@ interface SimpleExpectedOptionsType { } describe("Command Framework", () => { - before(silenceLogger); + beforeAll(silenceLogger); describe("subCommand", () => { it("simple dispatcher", async () => { diff --git a/common/tools/dev-tool/test/resolveProject.spec.ts b/common/tools/dev-tool/test/resolveProject.spec.ts index ba46643fc39b..1f0a948904e4 100644 --- a/common/tools/dev-tool/test/resolveProject.spec.ts +++ b/common/tools/dev-tool/test/resolveProject.spec.ts @@ -1,22 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license -import { assert, use as chaiUse } from "chai"; -import chaiPromises from "chai-as-promised"; -chaiUse(chaiPromises); - -import path from "path"; - +import { describe, it, assert, expect } from "vitest"; +import path from "node:path"; import { resolveProject } from "../src/util/resolveProject"; describe("Project Resolution", () => { it("resolution halts at monorepo root", async () => { - await assert.isRejected(resolveProject(path.join(__dirname, "..", "..")), /monorepo root/); + await expect(resolveProject(path.join(__dirname, "..", ".."))).rejects.toThrow(/monorepo root/); }); it("resolution halts at filesystem root", async () => { const p = path.join(__dirname, "..", "..", "..", "..", ".."); - await assert.isRejected(resolveProject(p), /filesystem root/); + await expect(resolveProject(p)).rejects.toThrow(/filesystem root/); }); it("resolution finds dev-tool package", async () => { diff --git a/common/tools/dev-tool/test/samples/files.spec.ts b/common/tools/dev-tool/test/samples/files.spec.ts index 56baa50f606e..7b8fd1d569bb 100644 --- a/common/tools/dev-tool/test/samples/files.spec.ts +++ b/common/tools/dev-tool/test/samples/files.spec.ts @@ -1,14 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { describe, it, assert } from "vitest"; import fs from "fs-extra"; -import os from "os"; -import path from "path"; +import os from "node:os"; +import path from "node:path"; import { makeSamplesFactory } from "../../src/util/samples/generation"; - import * as git from "../../src/util/git"; - -import { assert } from "chai"; import { findMatchingFiles } from "../../src/util/findMatchingFiles"; import { METADATA_KEY } from "../../src/util/resolveProject"; @@ -17,7 +15,7 @@ import { METADATA_KEY } from "../../src/util/resolveProject"; const INPUT_PATH = path.join(__dirname, "files", "inputs"); const EXPECT_PATH = path.join(__dirname, "files", "expectations"); -describe("File content tests", async function () { +describe("File content tests", { timeout: 50000 }, async function () { const shouldWriteExpectations = process.env.TEST_MODE === "record"; if (shouldWriteExpectations) { @@ -44,7 +42,7 @@ describe("File content tests", async function () { for (const dir of inputDirectories) { const name = path.basename(dir); - it(name, async function () { + it(name, { timeout: 50000 }, async function () { const tempOutputDir = await fs.mkdtemp(path.join(os.tmpdir(), "devToolTest")); const version = name.includes("@") ? name.split("@")[1] : "1.0.0"; @@ -115,6 +113,6 @@ describe("File content tests", async function () { await fs.emptyDir(tempOutputDir); await fs.rmdir(tempOutputDir); } - }).timeout(50000); + }); } -}).timeout(50000); +}); diff --git a/common/tools/dev-tool/test/samples/skips.spec.ts b/common/tools/dev-tool/test/samples/skips.spec.ts index 41514fc28dbe..228fae3b2a6a 100644 --- a/common/tools/dev-tool/test/samples/skips.spec.ts +++ b/common/tools/dev-tool/test/samples/skips.spec.ts @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { assert } from "chai"; - +import { describe, it, assert } from "vitest"; import { FileInfo } from "../../src/util/findMatchingFiles"; import { shouldSkip } from "../../src/util/samples/configuration"; diff --git a/common/tools/dev-tool/vitest.config.ts b/common/tools/dev-tool/vitest.config.ts new file mode 100644 index 000000000000..16d0436c006f --- /dev/null +++ b/common/tools/dev-tool/vitest.config.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + reporters: ["basic", "junit"], + outputFile: { + junit: "test-results.xml", + }, + fakeTimers: { + toFake: ["setTimeout", "Date"], + }, + watch: false, + include: ["test/**/*.spec.ts", "test/*.spec.ts"], + coverage: { + include: ["src/**/*.ts"], + exclude: [ + "src/**/*-browser.mts", + "src/**/*-react-native.mts", + "vitest*.config.ts", + "samples-dev/**/*.ts", + ], + provider: "istanbul", + reporter: ["text", "json", "html"], + reportsDirectory: "coverage", + }, + }, +});