// Runs the integration suite inside a real VS Code instance with a throwaway // profile. Uses the locally installed VS Code when VSCODE_PATH is set or the // default macOS location exists; otherwise downloads one. import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { runTests } from '@vscode/test-electron'; // When launched from a VS Code terminal this is inherited and would make the // test instance start as plain Node. delete process.env.ELECTRON_RUN_AS_NODE; const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..'); const macApp = '/Applications/Visual Studio Code.app/Contents/MacOS/Code'; const vscodeExecutablePath = process.env.VSCODE_PATH || (fs.existsSync(macApp) ? macApp : undefined); const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-ext-it-')); const workspace = path.join(scratch, 'workspace'); fs.cpSync(path.join(root, 'test', 'fixtures'), workspace, { recursive: true }); try { await runTests({ vscodeExecutablePath, extensionDevelopmentPath: root, extensionTestsPath: path.join(root, 'out', 'test', 'integration', 'suite.js'), launchArgs: [ workspace, '--disable-extensions', '--disable-workspace-trust', '--skip-welcome', '--skip-release-notes', `--user-data-dir=${path.join(scratch, 'user-data')}`, ], }); } finally { fs.rmSync(scratch, { recursive: true, force: true }); }