Skip to content

Commit 5945aa2

Browse files
fix(typespec-vscode): fix e2e create-project test failing on peer dep conflicts (#10306)
After each release, core packages (e.g. `@typespec/rest@0.81.0`) bump to new versions before emitter packages (`@typespec/http-client-js@0.14.1` still peers on `@typespec/rest@^0.80.0`). The e2e test scaffolds a project with all deps set to `"latest"` and selects all emitters, so `npm install` fails with `ERESOLVE` — no `node_modules` or `package-lock.json` created. The test then does an exact file list assertion that includes those install artifacts and fails. ### Changes - **Remove install artifacts from expected files** in `create-typespec.test.ts` — `node_modules` and `package-lock.json` depend on npm registry state and are not what this test validates (the UI scaffolding flow is) - **Switch `expectFilesInDir` to subset matching** (`expect.arrayContaining`) so the assertion passes whether install succeeds or not, without masking missing scaffolded files - Fix pre-existing typo: `exected` → `expected` in the touched function --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
1 parent 442eaac commit 5945aa2

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

packages/typespec-vscode/test/extension/common/common-steps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ export async function preContrastResult(
3232

3333
/**
3434
* Results comparison
35-
* @param exected List of expected files
35+
* @param expected List of expected files that must be present in the directory
3636
* @param dir The directory to be compared needs to be converted into an absolute path using path.resolve
3737
*/
38-
export async function expectFilesInDir(exected: string[], dir: string) {
38+
export async function expectFilesInDir(expected: string[], dir: string) {
3939
const results = await readdir(dir);
40-
expect(results).toEqual(exected);
40+
expect(results).toEqual(expect.arrayContaining(expected));
4141
}
4242

4343
/**

packages/typespec-vscode/test/extension/create-typespec.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@ const CreateTypespecProjectFolderPath = path.resolve(tempDir, "CreateTypespecPro
3131
const createCase = "CreateTypespecProject";
3232
const templateName = "Generic Rest API";
3333
const templateNameDescription = "Create a project representing a generic REST API service.";
34-
const expectedResults = [
35-
".gitignore",
36-
"main.tsp",
37-
"node_modules",
38-
"package-lock.json",
39-
"package.json",
40-
"tspconfig.yaml",
41-
];
34+
const expectedResults = [".gitignore", "main.tsp", "package.json", "tspconfig.yaml"];
4235

4336
const CreateCasesConfigList: CreateConfigType[] = [
4437
{

0 commit comments

Comments
 (0)