-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollect.e2e.test.ts
More file actions
53 lines (46 loc) · 1.66 KB
/
collect.e2e.test.ts
File metadata and controls
53 lines (46 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { cp } from 'node:fs/promises';
import path from 'node:path';
import { afterAll, beforeAll, expect } from 'vitest';
import { type Report, reportSchema } from '@code-pushup/models';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
omitVariableReportData,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
describe('PLUGIN collect report with js-benchmark-plugin NPM package', () => {
const envDir = path.join(E2E_ENVIRONMENTS_DIR, nxTargetProject());
const testFileDir = path.join(envDir, TEST_OUTPUT_DIR, 'collect');
const fixturesDir = path.join(
'e2e',
nxTargetProject(),
'mocks/fixtures/default-setup',
);
beforeAll(async () => {
await cp(fixturesDir, envDir, { recursive: true });
await restoreNxIgnoredFiles(envDir);
});
afterAll(async () => {
await teardownTestFolder(testFileDir);
});
it('should run plugin over CLI and creates report.json', async () => {
const { code, stdout } = await executeProcess({
command: 'npx',
// verbose exposes audits with perfect scores that are hidden in the default stdout
args: ['@code-pushup/cli', 'collect', '--verbose'],
cwd: envDir,
});
expect(code).toBe(0);
expect(stdout).toContain('JS Benchmark audits');
const report = await readJsonFile(
path.join(envDir, '.code-pushup', 'report.json'),
);
expect(() => reportSchema.parse(report)).not.toThrowError();
expect(
omitVariableReportData(report as Report, { omitAuditData: true }),
).toMatchSnapshot();
});
});