Skip to content

Commit 74c39cb

Browse files
committed
fix: wip e2e
1 parent 7cf9479 commit 74c39cb

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

e2e/nx-plugin-e2e/tests/executor-cli.e2e.test.ts

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
import { type Tree, updateProjectConfiguration } from '@nx/devkit';
1+
import {type Tree, updateProjectConfiguration} from '@nx/devkit';
22
import path from 'node:path';
3-
import { readProjectConfiguration } from 'nx/src/generators/utils/project-configuration';
4-
import { afterEach, expect } from 'vitest';
5-
import {
6-
type AutorunCommandExecutorOptions,
7-
generateCodePushupConfig,
8-
} from '@code-pushup/nx-plugin';
9-
import {
10-
generateWorkspaceAndProject,
11-
materializeTree,
12-
nxTargetProject,
13-
} from '@code-pushup/test-nx-utils';
14-
import {
15-
E2E_ENVIRONMENTS_DIR,
16-
TEST_OUTPUT_DIR,
17-
removeColorCodes,
18-
teardownTestFolder,
19-
} from '@code-pushup/test-utils';
20-
import { executeProcess, readJsonFile } from '@code-pushup/utils';
21-
import { INLINE_PLUGIN } from './inline-plugin.js';
3+
import {readProjectConfiguration} from 'nx/src/generators/utils/project-configuration';
4+
import {afterAll, afterEach, beforeEach, expect, vi} from 'vitest';
5+
import {type AutorunCommandExecutorOptions, generateCodePushupConfig,} from '@code-pushup/nx-plugin';
6+
import {generateWorkspaceAndProject, materializeTree, nxTargetProject,} from '@code-pushup/test-nx-utils';
7+
import {E2E_ENVIRONMENTS_DIR, removeColorCodes, teardownTestFolder, TEST_OUTPUT_DIR,} from '@code-pushup/test-utils';
8+
import {executeProcess, readJsonFile} from '@code-pushup/utils';
9+
import {INLINE_PLUGIN} from './inline-plugin.js';
2210

2311
async function addTargetToWorkspace(
2412
tree: Tree,
@@ -58,19 +46,32 @@ describe('executor command', () => {
5846
TEST_OUTPUT_DIR,
5947
'executor-cli',
6048
);
49+
const processEnvCP = Object.fromEntries(
50+
Object.entries(process.env).filter(([k]) => k.startsWith('CP_')),
51+
);
52+
53+
/* eslint-disable functional/immutable-data, @typescript-eslint/no-dynamic-delete */
54+
beforeAll(() => {
55+
Object.entries(process.env)
56+
.filter(([k]) => k.startsWith('CP_'))
57+
.forEach(([k]) => delete process.env[k]);
58+
});
6159

62-
beforeEach(async () => {
60+
beforeEach(() => {
61+
vi.unstubAllEnvs();
6362
tree = await generateWorkspaceAndProject(project);
64-
vi.stubEnv('CP_ORGANIZATION', '');
65-
vi.stubEnv('CP_PROJECT', '');
66-
vi.stubEnv('CP_SERVER', '');
67-
vi.stubEnv('CP_API_KEY', '');
6863
});
6964

7065
afterEach(async () => {
7166
await teardownTestFolder(testFileDir);
7267
});
7368

69+
afterAll(() => {
70+
Object.entries(processEnvCP).forEach(([k, v]) => (process.env[k] = v));
71+
});
72+
/* eslint-enable functional/immutable-data, @typescript-eslint/no-dynamic-delete */
73+
74+
7475
it('should execute no specific command by default', async () => {
7576
const cwd = path.join(testFileDir, 'execute-default-command');
7677
await addTargetToWorkspace(tree, { cwd, project });

0 commit comments

Comments
 (0)