Skip to content

Commit

Permalink
test: simplify fixture paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Jahed Ahmed committed Aug 11, 2021
1 parent 97f1dc3 commit 8e296a6
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions test/jest/acceptance/analytics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { fakeServer } from '../../acceptance/fake-server';
import { createProject } from '../util/createProject';
import {
createProjectFromFixture,
createProjectFromWorkspace,
} from '../util/createProject';
import { runSnykCLI } from '../util/runSnykCLI';
import * as fs from 'fs';

jest.setTimeout(1000 * 30);

Expand Down Expand Up @@ -38,7 +40,7 @@ describe('analytics module', () => {
});

it('sends analytics for `snyk test` with no vulns found', async () => {
const project = await createProject('../acceptance/workspaces/npm-package');
const project = await createProjectFromWorkspace('npm-package');
const { code } = await runSnykCLI('test', {
cwd: project.path(),
env,
Expand Down Expand Up @@ -102,14 +104,11 @@ describe('analytics module', () => {
});

it('sends analytics for `snyk test` with vulns found', async () => {
const testDepGraphResult = JSON.parse(
fs.readFileSync(
'test/fixtures/npm/with-vulnerable-lodash-dep/test-dep-graph-result.json',
'utf-8',
),
const project = await createProjectFromFixture(
'npm/with-vulnerable-lodash-dep',
);
server.setNextResponse(testDepGraphResult);
const project = await createProject('npm/with-vulnerable-lodash-dep');

server.setNextResponse(await project.read('test-dep-graph-result.json'));

const { code } = await runSnykCLI('test', {
cwd: project.path(),
Expand Down Expand Up @@ -184,7 +183,7 @@ describe('analytics module', () => {
});

it('sends correct analytics data a bad command', async () => {
const project = await createProject('../acceptance/workspaces/npm-package');
const project = await createProjectFromWorkspace('npm-package');
const { code } = await runSnykCLI('random-nonsense-command --some-option', {
cwd: project.path(),
env,
Expand Down Expand Up @@ -247,7 +246,7 @@ describe('analytics module', () => {
});

it('sends analytics data a bad command', async () => {
const project = await createProject('../acceptance/workspaces/npm-package');
const project = await createProjectFromWorkspace('npm-package');
const { code } = await runSnykCLI('', {
cwd: project.path(),
env,
Expand Down

0 comments on commit 8e296a6

Please sign in to comment.