import * as path from "path"; import * as os from "os"; import * as fs from "fs"; import { runTests } from "@vscode/test-electron"; async function main(): Promise { const projectRoot = path.resolve(__dirname, "../../../"); const extensionDevelopmentPath = projectRoot; const extensionTestsPath = path.resolve(__dirname, "./suite/index"); // Copy the fixture workspace to a temp dir so test writes are throwaway. const fixture = path.resolve(projectRoot, "test/e2e/fixtures/workspace"); const workspace = fs.mkdtempSync(path.join(os.tmpdir(), "cowriting-e2e-")); fs.cpSync(fixture, workspace, { recursive: true }); try { await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs: [workspace, "--disable-extensions"], extensionTestsEnv: { E2E_WORKSPACE: workspace }, }); // Second pass — NO workspace folder (regression for #8): commands must // exist as warning stubs instead of erroring "command not found". await runTests({ extensionDevelopmentPath, extensionTestsPath: path.resolve(__dirname, "./suite-no-workspace/index"), launchArgs: ["--disable-extensions"], }); } finally { fs.rmSync(workspace, { recursive: true, force: true }); } } main().catch((err) => { console.error("E2E run failed:", err); process.exit(1); });