From 8e9825efbd53706de31fee17a3c0fc254525f3a2 Mon Sep 17 00:00:00 2001 From: Jason Dent Date: Fri, 2 Aug 2024 15:43:59 +0200 Subject: [PATCH] test: fix insiders integration test (#3499) --- packages/_integrationTests/src/extension.test.mts | 12 ++++++++---- packages/_integrationTests/src/helper.mts | 7 ++++--- packages/_integrationTests/src/runTests.mts | 10 +++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/_integrationTests/src/extension.test.mts b/packages/_integrationTests/src/extension.test.mts index 44da6cde0..e5c926733 100644 --- a/packages/_integrationTests/src/extension.test.mts +++ b/packages/_integrationTests/src/extension.test.mts @@ -65,10 +65,14 @@ describe('Launch code spell extension', function () { this.timeout(120000); const docUri = getDocUri('diagnostics.txt'); - this.beforeAll(async () => { - await loadFolder(getDocUri('.')); - await activateExtension(); - }); + this.beforeAll( + logError(async () => { + await activateExtension(); + logYellow('Activated'); + logYellow('Load Folder %o', getDocUri('./').toJSON()); + await loadFolder(getDocUri('./')); + }), + ); it( 'Verify the extension starts', diff --git a/packages/_integrationTests/src/helper.mts b/packages/_integrationTests/src/helper.mts index e38f01dff..6ccb9d05e 100644 --- a/packages/_integrationTests/src/helper.mts +++ b/packages/_integrationTests/src/helper.mts @@ -13,7 +13,7 @@ export { log } from './logger.mjs'; const require = createRequire(import.meta.url); -const __dirname = fileURLToPath(new URL('.', import.meta.url)); +const __dirname = fileURLToPath(new URL('./', import.meta.url)); const extensionPackage = require('../../../package.json'); const fixturesPath = path.resolve(__dirname, '../testFixtures'); @@ -70,7 +70,7 @@ export async function loadDocument(docUri: Uri): Promise { - return await vscode.commands.executeCommand('vscode.openFolder', folderUri); + return await vscode.commands.executeCommand('vscode.openFolder', folderUri, { forceNewWindow: false, forceReuseWindow: true }); } export function getVscodeWorkspace(): typeof vscode.workspace { @@ -85,7 +85,8 @@ export const getDocPath = (p: string) => { return path.resolve(fixturesPath, p); }; export const getDocUri = (p: string) => { - return vscode.Uri.file(getDocPath(p)); + const r = getDocPath(p) + (p.endsWith('/') ? '/' : ''); + return vscode.Uri.file(r); }; export async function setTestContent(context: DocumentContext, content: string): Promise { diff --git a/packages/_integrationTests/src/runTests.mts b/packages/_integrationTests/src/runTests.mts index dd91c6c69..5bdde9d4b 100644 --- a/packages/_integrationTests/src/runTests.mts +++ b/packages/_integrationTests/src/runTests.mts @@ -5,16 +5,16 @@ import { fileURLToPath } from 'node:url'; import { downloadAndUnzipVSCode, runTests } from '@vscode/test-electron'; import decompress from 'decompress'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = fileURLToPath(new URL('.', import.meta.url)); +const __dirname = fileURLToPath(new URL('./', import.meta.url)); const root = path.resolve(__dirname, '../../../'); +const fixtureFolder = path.resolve(__dirname, '../testFixtures'); const cacheDirName = '.vscode-test'; async function run(version: undefined | 'stable' | 'insiders' | string, extensionDevelopmentPath: string) { // Delete `.vscode-test` to prevent socket issues - await fs.rm(cacheDirName, { recursive: true, force: true }); - await fs.rm(path.resolve(root, cacheDirName), { recursive: true, force: true }); + // await fs.rm(cacheDirName, { recursive: true, force: true }); + // await fs.rm(path.resolve(root, cacheDirName), { recursive: true, force: true }); // try and have a short path to prevent socket errors. const cachePath = path.join(root, cacheDirName); @@ -23,7 +23,7 @@ async function run(version: undefined | 'stable' | 'insiders' | string, extensio // Passed to --extensionTestsPath const extensionTestsPath = path.resolve(__dirname, './index.cjs'); - const fileToOpen = path.relative(process.cwd(), __filename); + const fileToOpen = path.relative(process.cwd(), fixtureFolder); const launchArgs: string[] = [ '--disable-extensions', fileToOpen,