-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcollect.e2e.test.ts
More file actions
72 lines (63 loc) · 2.29 KB
/
collect.e2e.test.ts
File metadata and controls
72 lines (63 loc) · 2.29 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
import { cp } from 'node:fs/promises';
import path from 'node:path';
import { simpleGit } from 'simple-git';
import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest';
import { type Report, reportSchema } from '@code-pushup/models';
import { omitVariableReportData } from '@code-pushup/test-fixtures';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
initGitRepo,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
describe('PLUGIN collect report with jsdocs-plugin NPM package', () => {
const fixturesDir = path.join(
'e2e',
'plugin-jsdocs-e2e',
'mocks',
'fixtures',
);
const fixturesAngularDir = path.join(fixturesDir, 'angular');
const fixturesReactDir = path.join(fixturesDir, 'react');
const envRoot = path.join(
E2E_ENVIRONMENTS_DIR,
nxTargetProject(),
TEST_OUTPUT_DIR,
);
const angularDir = path.join(envRoot, 'angular');
const reactDir = path.join(envRoot, 'react');
const angularOutputDir = path.join(angularDir, '.code-pushup');
const reactOutputDir = path.join(reactDir, '.code-pushup');
beforeAll(async () => {
await cp(fixturesAngularDir, angularDir, { recursive: true });
await cp(fixturesReactDir, reactDir, { recursive: true });
await restoreNxIgnoredFiles(angularDir);
await restoreNxIgnoredFiles(reactDir);
await initGitRepo(simpleGit, { baseDir: angularDir });
await initGitRepo(simpleGit, { baseDir: reactDir });
});
afterAll(async () => {
await teardownTestFolder(angularDir);
await teardownTestFolder(reactDir);
});
afterEach(async () => {
await teardownTestFolder(angularOutputDir);
await teardownTestFolder(reactOutputDir);
});
it('should run JSDoc plugin for Angular example dir and create report.json', async () => {
const { code } = await executeProcess({
command: 'npx',
args: ['@code-pushup/cli', 'collect'],
cwd: angularDir,
});
expect(code).toBe(0);
const report = await readJsonFile<Report>(
path.join(angularOutputDir, 'report.json'),
);
expect(() => reportSchema.parse(report)).not.toThrow();
expect(omitVariableReportData(report)).toMatchSnapshot();
});
});