Skip to content

Commit

Permalink
test: fix insiders integration test (#3499)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Aug 2, 2024
1 parent c048d16 commit 8e9825e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
12 changes: 8 additions & 4 deletions packages/_integrationTests/src/extension.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 4 additions & 3 deletions packages/_integrationTests/src/helper.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function loadDocument(docUri: Uri): Promise<DocumentContext | undef
}

export async function loadFolder(folderUri: Uri): Promise<void> {
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 {
Expand All @@ -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<boolean> {
Expand Down
10 changes: 5 additions & 5 deletions packages/_integrationTests/src/runTests.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down

0 comments on commit 8e9825e

Please sign in to comment.