Skip to content

Commit 5ca2b06

Browse files
committed
refactor: wip
1 parent 41c9469 commit 5ca2b06

1 file changed

Lines changed: 70 additions & 70 deletions

File tree

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,82 @@
1-
import {cp} from 'node:fs/promises';
1+
import { cp } from 'node:fs/promises';
22
import path from 'node:path';
3-
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
4-
import {auditOutputsSchema} from '@code-pushup/models';
5-
import {nxTargetProject} from '@code-pushup/test-nx-utils';
3+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
4+
import { auditOutputsSchema } from '@code-pushup/models';
5+
import { nxTargetProject } from '@code-pushup/test-nx-utils';
66
import {
7-
E2E_ENVIRONMENTS_DIR,
8-
TEST_OUTPUT_DIR,
9-
restoreNxIgnoredFiles,
10-
teardownTestFolder,
7+
E2E_ENVIRONMENTS_DIR,
8+
TEST_OUTPUT_DIR,
9+
restoreNxIgnoredFiles,
10+
teardownTestFolder,
1111
} from '@code-pushup/test-utils';
12-
import {executeProcess, readJsonFile} from '@code-pushup/utils';
12+
import { executeProcess, readJsonFile } from '@code-pushup/utils';
1313

1414
describe('knip reporter for code pushup audits', () => {
15-
const envDir = path.join(E2E_ENVIRONMENTS_DIR, nxTargetProject());
16-
const testFileDir = path.join(envDir, TEST_OUTPUT_DIR, 'reporter');
17-
const reporterSetupDir = path.join(testFileDir, 'reporter-setup');
18-
const fixturesDir = path.join('e2e', nxTargetProject(), 'mocks/fixtures');
19-
const reporterPath = path.resolve(
20-
envDir,
21-
'node_modules',
22-
'@code-pushup',
23-
'knip-plugin',
24-
'src',
25-
'lib',
26-
'reporter.js',
27-
);
15+
const envDir = path.join(E2E_ENVIRONMENTS_DIR, nxTargetProject());
16+
const testFileDir = path.join(envDir, TEST_OUTPUT_DIR, 'reporter');
17+
const reporterSetupDir = path.join(testFileDir, 'reporter-setup');
18+
const fixturesDir = path.join('e2e', nxTargetProject(), 'mocks/fixtures');
19+
const reporterPath = path.resolve(
20+
envDir,
21+
'node_modules',
22+
'@code-pushup',
23+
'knip-plugin',
24+
'src',
25+
'lib',
26+
'reporter.js',
27+
);
2828

29-
beforeAll(async () => {
30-
await cp(fixturesDir, testFileDir, {recursive: true});
31-
await restoreNxIgnoredFiles(testFileDir);
32-
});
29+
beforeAll(async () => {
30+
await cp(fixturesDir, testFileDir, { recursive: true });
31+
await restoreNxIgnoredFiles(testFileDir);
32+
});
3333

34-
afterAll(async () => {
35-
await teardownTestFolder(testFileDir);
36-
});
34+
afterAll(async () => {
35+
await teardownTestFolder(testFileDir);
36+
});
3737

38-
it('should execute knip with custom reporter and generate report', async () => {
39-
const outputFile = path.join(reporterSetupDir, 'knip-report.json');
38+
it('should execute knip with custom reporter and generate report', async () => {
39+
const outputFile = path.join(reporterSetupDir, 'knip-report.json');
4040

41-
const {code} = await executeProcess({
42-
command: 'npx',
43-
args: [
44-
'knip',
45-
'--no-exit-code',
46-
`--reporter=${reporterPath}`,
47-
/* eslint-disable-next-line no-useless-escape */
48-
`--reporter-options={\"outputFile\":\"knip-report.json\"}'`,
49-
],
50-
cwd: reporterSetupDir,
51-
});
41+
const { code } = await executeProcess({
42+
command: 'npx',
43+
args: [
44+
'knip',
45+
'--no-exit-code',
46+
`--reporter=${reporterPath}`,
47+
/* eslint-disable-next-line no-useless-escape */
48+
`--reporter-options={\"outputFile\":\"knip-report.json\"}'`,
49+
],
50+
cwd: reporterSetupDir,
51+
});
5252

53-
expect(code).toBe(0);
53+
expect(code).toBe(0);
5454

55-
const report = await readJsonFile(outputFile);
56-
expect(() => auditOutputsSchema.parse(report)).not.toThrowError();
57-
expect(report).toStrictEqual(
58-
expect.arrayContaining([
59-
expect.objectContaining({
60-
slug: 'dependencies',
61-
score: 0,
62-
value: 1,
63-
details: {
64-
issues: [
65-
{
66-
message: 'Unused dependency zod',
67-
severity: 'error',
68-
source: {
69-
"file": "tmp/e2e/plugin-knip-e2e/__test__/reporter/reporter-setup/package.json",
70-
"position": {
71-
"startColumn": 6,
72-
"startLine": 4,
73-
},
74-
},
75-
},
76-
],
77-
},
78-
}),
79-
]),
80-
);
81-
});
55+
const report = await readJsonFile(outputFile);
56+
expect(() => auditOutputsSchema.parse(report)).not.toThrowError();
57+
expect(report).toStrictEqual(
58+
expect.arrayContaining([
59+
expect.objectContaining({
60+
slug: 'dependencies',
61+
score: 0,
62+
value: 1,
63+
details: {
64+
issues: [
65+
{
66+
message: 'Unused dependency zod',
67+
severity: 'error',
68+
source: {
69+
file: 'tmp/e2e/plugin-knip-e2e/__test__/reporter/reporter-setup/package.json',
70+
position: {
71+
startColumn: 6,
72+
startLine: 4,
73+
},
74+
},
75+
},
76+
],
77+
},
78+
}),
79+
]),
80+
);
81+
});
8282
});

0 commit comments

Comments
 (0)