Skip to content

Commit

Permalink
feat: [OSM-1040] added acceptance tests for pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
gemaxim committed Apr 29, 2024
1 parent ab7ad73 commit dd21adb
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 12 deletions.
224 changes: 215 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -122,7 +122,7 @@
"snyk-module": "3.1.0",
"snyk-mvn-plugin": "3.4.2",
"snyk-nodejs-lockfile-parser": "1.53.1",
"snyk-nodejs-plugin": "1.0.1",
"snyk-nodejs-plugin": "1.0.2",
"snyk-nuget-plugin": "2.4.3",
"snyk-php-plugin": "1.9.2",
"snyk-policy": "^1.25.0",
Expand Down
1 change: 1 addition & 0 deletions test/acceptance/fake-server.ts
Expand Up @@ -13,6 +13,7 @@ const featureFlagDefaults = (): Map<string, boolean> => {
['cliFailFast', false],
['iacIntegratedExperience', false],
['containerCliAppVulnsEnabled', true],
['enablePnpmCli', false],
]);
};

Expand Down
56 changes: 55 additions & 1 deletion test/jest/acceptance/snyk-test/all-projects.spec.ts
@@ -1,4 +1,7 @@
import { createProjectFromWorkspace } from '../../util/createProject';
import {
createProjectFromFixture,
createProjectFromWorkspace,
} from '../../util/createProject';
import { runSnykCLI } from '../../util/runSnykCLI';
import { fakeServer } from '../../../acceptance/fake-server';
import { getServerPort } from '../../util/getServerPort';
Expand Down Expand Up @@ -226,4 +229,55 @@ describe('snyk test --all-projects (mocked server only)', () => {
expect(stdout).toMatch('Package manager: composer');
expect(stderr).toEqual('');
});

test('`test node workspaces --all-projects`', async () => {
server.setFeatureFlag('enablePnpmCli', false);
const project = await createProjectFromFixture('workspace-multi-type');

const { code, stdout } = await runSnykCLI('test --all-projects', {
cwd: project.path(),
env,
});

const backendRequests = server.popRequests(1);
expect(backendRequests).toHaveLength(1);

backendRequests.forEach((req) => {
expect(req.method).toEqual('POST');
expect(req.headers['x-snyk-cli-version']).not.toBeUndefined();
expect(req.url).toMatch('/api/v1/test');
});

expect(code).toEqual(0);

expect(stdout).toMatch('Package manager: npm');
expect(stdout).toMatch('Package manager: yarn');
expect(stdout).not.toMatch('Package manager: pnpm');
});

test('`test node workspaces --all-projects with `enablePnpmCli` feature flag`', async () => {
server.setFeatureFlag('enablePnpmCli', true);

const project = await createProjectFromFixture('workspace-multi-type');

const { code, stdout } = await runSnykCLI('test --all-projects', {
cwd: project.path(),
env,
});

const backendRequests = server.popRequests(1);
expect(backendRequests).toHaveLength(1);

backendRequests.forEach((req) => {
expect(req.method).toEqual('POST');
expect(req.headers['x-snyk-cli-version']).not.toBeUndefined();
expect(req.url).toMatch('/api/v1/test');
});

expect(code).toEqual(0);

expect(stdout).toMatch('Package manager: npm');
expect(stdout).toMatch('Package manager: yarn');
expect(stdout).toMatch('Package manager: pnpm');
});
});

0 comments on commit dd21adb

Please sign in to comment.