diff --git a/test/jest/acceptance/analytics.spec.ts b/test/jest/acceptance/analytics.spec.ts index 61bddb0d55..122b63f413 100644 --- a/test/jest/acceptance/analytics.spec.ts +++ b/test/jest/acceptance/analytics.spec.ts @@ -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); @@ -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, @@ -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(), @@ -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, @@ -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,