-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathauth.e2e.test.ts
More file actions
66 lines (58 loc) · 1.68 KB
/
auth.e2e.test.ts
File metadata and controls
66 lines (58 loc) · 1.68 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
import { cp } from 'node:fs/promises';
import type { Server } from 'node:http';
import path from 'node:path';
import type { Report } from '@code-pushup/models';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
import {
createAuthServer,
startServer,
stopServer,
} from '../mocks/fixtures/auth/server/server.js';
describe('PLUGIN collect with setupScript authentication', () => {
const PORT = 8080;
const fixturesDir = path.join(
'e2e',
nxTargetProject(),
'mocks',
'fixtures',
'auth',
);
const testFileDir = path.join(
E2E_ENVIRONMENTS_DIR,
nxTargetProject(),
TEST_OUTPUT_DIR,
'auth',
);
let server: Server;
beforeAll(async () => {
await cp(fixturesDir, testFileDir, { recursive: true });
await restoreNxIgnoredFiles(testFileDir);
server = createAuthServer(path.join(testFileDir, 'server'));
await startServer(server, PORT);
});
afterAll(async () => {
await stopServer(server);
await teardownTestFolder(testFileDir);
});
it('should analyze authenticated page using setupScript', async () => {
const { code } = await executeProcess({
command: 'npx',
args: ['@code-pushup/cli', 'collect'],
cwd: testFileDir,
});
expect(code).toBe(0);
const report = await readJsonFile<Report>(
path.join(testFileDir, '.code-pushup', 'report.json'),
);
expect(report.plugins[0]!.audits).toSatisfyAny(
audit => audit.score < 1 && audit.slug === 'th-has-data-cells',
);
});
});