From 14f2e0aa4341f950002b249dad27b574ca12122f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Scha=CC=88fer?= <101886095+PeterSchafer@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:18:13 +0200 Subject: [PATCH] test: improve ls test --- .../language-server-extension.spec.ts | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/test/jest/acceptance/language-server-extension.spec.ts b/test/jest/acceptance/language-server-extension.spec.ts index 9040d3ee3e..0364668967 100644 --- a/test/jest/acceptance/language-server-extension.spec.ts +++ b/test/jest/acceptance/language-server-extension.spec.ts @@ -3,8 +3,9 @@ import { pathToFileURL } from 'url'; import { sleep } from '../../../src/lib/common'; import * as cp from 'child_process'; import * as rpc from 'vscode-jsonrpc/node'; +import { createProject } from '../util/createProject'; -jest.setTimeout(1000 * 120); +jest.setTimeout(1000 * 180); describe('Language Server Extension', () => { it('get ls licenses', async () => { @@ -29,6 +30,17 @@ describe('Language Server Extension', () => { }); it('run and wait for diagnostics', async () => { + const loop = 10; + const folders: any = []; + + for (let i = 0; i < loop; i++) { + const project = await createProject('npm/with-vulnerable-lodash-dep'); + folders.push({ + name: `workspace ${i}`, + uri: pathToFileURL(project.path()).href, + }); + } + let cmd = ''; if (process.env.TEST_SNYK_COMMAND !== undefined) { cmd = process.env.TEST_SNYK_COMMAND; @@ -55,12 +67,7 @@ describe('Language Server Extension', () => { name: 'FakeIDE', version: '4.5.6', }, - workspaceFolders: [ - { - name: 'workspace', - uri: pathToFileURL('.').href, - }, - ], + workspaceFolders: folders, rootUri: null, initializationOptions: { activateSnykCodeSecurity: 'false', @@ -98,9 +105,9 @@ describe('Language Server Extension', () => { await connection.sendRequest('initialized', {}); - for (let i = 0; i < 45; i++) { + for (let i = 0; i < 1000; i++) { console.debug('Waiting for diagnostics...'); - if (diagnosticCount > 0) { + if (diagnosticCount >= loop) { break; } await sleep(1000);