-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathprint-config.e2e.test.ts
More file actions
83 lines (76 loc) · 2.25 KB
/
print-config.e2e.test.ts
File metadata and controls
83 lines (76 loc) · 2.25 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { cp, readFile } from 'node:fs/promises';
import path from 'node:path';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess } from '@code-pushup/utils';
describe('CLI print-config', () => {
const extensions = ['js', 'mjs', 'ts'] as const;
const fixtureDummyDir = path.join(
'e2e',
nxTargetProject(),
'mocks',
'fixtures',
'dummy-setup',
);
const testFileDir = path.join(
E2E_ENVIRONMENTS_DIR,
nxTargetProject(),
TEST_OUTPUT_DIR,
'print-config',
);
const testFileDummySetup = path.join(testFileDir, 'dummy-setup');
const configFilePath = (ext: (typeof extensions)[number]) =>
path.join(process.cwd(), testFileDummySetup, `code-pushup.config.${ext}`);
const tsconfigFilePath = path.join(
process.cwd(),
testFileDummySetup,
'tsconfig.base.json',
);
beforeAll(async () => {
await cp(fixtureDummyDir, testFileDummySetup, { recursive: true });
});
afterAll(async () => {
await teardownTestFolder(testFileDummySetup);
});
it.each(extensions)(
'should load .%s config file with correct arguments',
async ext => {
const { code } = await executeProcess({
command: 'npx',
args: [
'@code-pushup/cli',
'print-config',
'--output=config.json',
`--config=${configFilePath(ext)}`,
`--tsconfig=${tsconfigFilePath}`,
'--persist.outputDir=output-dir',
'--persist.format=md',
`--persist.filename=${ext}-report`,
],
cwd: testFileDummySetup,
});
expect(code).toBe(0);
const output = await readFile(
path.join(testFileDummySetup, 'config.json'),
'utf8',
);
expect(JSON.parse(output)).toEqual(
expect.objectContaining({
config: expect.stringContaining(`code-pushup.config.${ext}`),
tsconfig: tsconfigFilePath,
plugins: [
expect.objectContaining({
slug: 'dummy-plugin',
title: 'Dummy Plugin',
}),
],
categories: [expect.objectContaining({ slug: 'dummy-category' })],
}),
);
},
);
});