Skip to content

Commit

Permalink
test: improve ls test
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterSchafer committed Aug 20, 2024
1 parent d64068a commit 14f2e0a
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/jest/acceptance/language-server-extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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;
Expand All @@ -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',
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 14f2e0a

Please sign in to comment.