Skip to content

Commit b6d19ab

Browse files
committed
refactor: fix format
1 parent 93463a6 commit b6d19ab

5 files changed

Lines changed: 259 additions & 225 deletions

File tree

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,53 @@
1-
import {cp} from 'node:fs/promises';
1+
import { cp } from 'node:fs/promises';
22
import path from 'node:path';
3-
import {afterAll, beforeAll, expect} from 'vitest';
4-
import {type Report, reportSchema} from '@code-pushup/models';
5-
import {nxTargetProject} from '@code-pushup/test-nx-utils';
3+
import { afterAll, beforeAll, expect } from 'vitest';
4+
import { type Report, reportSchema } from '@code-pushup/models';
5+
import { nxTargetProject } from '@code-pushup/test-nx-utils';
66
import {
7-
E2E_ENVIRONMENTS_DIR,
8-
TEST_OUTPUT_DIR,
9-
omitVariableReportData,
10-
restoreNxIgnoredFiles,
11-
teardownTestFolder,
7+
E2E_ENVIRONMENTS_DIR,
8+
TEST_OUTPUT_DIR,
9+
omitVariableReportData,
10+
restoreNxIgnoredFiles,
11+
teardownTestFolder,
1212
} from '@code-pushup/test-utils';
13-
import {executeProcess, readJsonFile} from '@code-pushup/utils';
13+
import { executeProcess, readJsonFile } from '@code-pushup/utils';
1414

1515
describe('PLUGIN collect report with js-benchmark-plugin NPM package', () => {
16-
const envDir = path.join(
17-
E2E_ENVIRONMENTS_DIR,
18-
nxTargetProject()
19-
);
20-
const testFileDir = path.join(
21-
envDir,
22-
TEST_OUTPUT_DIR,
23-
'collect',
24-
);
25-
26-
const fixturesDir = path.join('e2e', nxTargetProject(), 'mocks/fixtures/default-setup');
27-
28-
beforeAll(async () => {
29-
await cp(fixturesDir, envDir, {recursive: true});
30-
await restoreNxIgnoredFiles(envDir);
31-
});
32-
33-
afterAll(async () => {
34-
await teardownTestFolder(testFileDir);
16+
const envDir = path.join(E2E_ENVIRONMENTS_DIR, nxTargetProject());
17+
const testFileDir = path.join(envDir, TEST_OUTPUT_DIR, 'collect');
18+
19+
const fixturesDir = path.join(
20+
'e2e',
21+
nxTargetProject(),
22+
'mocks/fixtures/default-setup',
23+
);
24+
25+
beforeAll(async () => {
26+
await cp(fixturesDir, envDir, { recursive: true });
27+
await restoreNxIgnoredFiles(envDir);
28+
});
29+
30+
afterAll(async () => {
31+
await teardownTestFolder(testFileDir);
32+
});
33+
34+
it('should run plugin over CLI and creates report.json', async () => {
35+
const { code, stdout } = await executeProcess({
36+
command: 'npx',
37+
// verbose exposes audits with perfect scores that are hidden in the default stdout
38+
args: ['@code-pushup/cli', 'collect', '--verbose'],
39+
cwd: envDir,
3540
});
3641

37-
it('should run plugin over CLI and creates report.json', async () => {
38-
const {code, stdout} = await executeProcess({
39-
command: 'npx',
40-
// verbose exposes audits with perfect scores that are hidden in the default stdout
41-
args: ['@code-pushup/cli', 'collect', '--verbose'],
42-
cwd: envDir,
43-
});
44-
45-
expect(code).toBe(0);
46-
expect(stdout).toContain('JS Benchmark audits');
47-
48-
const report = await readJsonFile(
49-
path.join(envDir, '.code-pushup', 'report.json'),
50-
);
51-
expect(() => reportSchema.parse(report)).not.toThrowError();
52-
expect(
53-
omitVariableReportData(report as Report, {omitAuditData: true}),
54-
).toMatchSnapshot();
55-
});
42+
expect(code).toBe(0);
43+
expect(stdout).toContain('JS Benchmark audits');
5644

45+
const report = await readJsonFile(
46+
path.join(envDir, '.code-pushup', 'report.json'),
47+
);
48+
expect(() => reportSchema.parse(report)).not.toThrowError();
49+
expect(
50+
omitVariableReportData(report as Report, { omitAuditData: true }),
51+
).toMatchSnapshot();
52+
});
5753
});

0 commit comments

Comments
 (0)