Skip to content

Commit 37f7cff

Browse files
author
John Doe
committed
refactor: fix e2e
1 parent 4824b91 commit 37f7cff

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('executor command', () => {
148148
).resolves.not.toThrow();
149149
});
150150

151-
it('should execute print-config executor with api key', async () => {
151+
it('should execute print-config executor with upload config', async () => {
152152
const cwd = path.join(testFileDir, 'execute-print-config-command');
153153
await addTargetToWorkspace(tree, { cwd, project });
154154

@@ -160,6 +160,9 @@ describe('executor command', () => {
160160
`${project}:code-pushup`,
161161
'print-config',
162162
'--upload.apiKey=a123a',
163+
'--upload.server=https://example.com',
164+
'--upload.organization=test-org',
165+
'--upload.project=test-project',
163166
],
164167
cwd,
165168
});
@@ -207,9 +210,15 @@ describe('executor command', () => {
207210
);
208211
expect(cleanStdout).toContain('Code PushUp CLI');
209212

210-
await expect(
211-
readJsonFile(path.join(cwd, '.reports', 'terminal-report.json')),
212-
).resolves.not.toThrow();
213+
// Check for report in project root's .reports directory
214+
const reportPath = path.join(
215+
cwd,
216+
'libs',
217+
project,
218+
'.reports',
219+
'terminal-report.json',
220+
);
221+
await expect(readJsonFile(reportPath)).resolves.not.toThrow();
213222
});
214223

215224
it('should execute collect executor and add report to sub folder named by project', async () => {
@@ -226,8 +235,9 @@ describe('executor command', () => {
226235
const cleanStdout = removeColorCodes(stdout);
227236
expect(cleanStdout).toContain('nx run my-lib:code-pushup collect');
228237

238+
// Check for report in project root's .code-pushup directory
229239
const report = await readJsonFile(
230-
path.join(cwd, '.code-pushup', project, 'report.json'),
240+
path.join(cwd, 'libs', project, '.code-pushup', 'report.json'),
231241
);
232242
expect(report).toStrictEqual(
233243
expect.objectContaining({

e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ describe('nx-plugin', () => {
199199
const cleanStdout = removeColorCodes(stdout);
200200
// Nx command
201201
expect(cleanStdout).toContain('nx run my-lib:code-pushup');
202-
// Run CLI executor
203-
expect(cleanStdout).toContain('Command: npx @code-pushup/cli');
202+
// Run CLI executor - check for DryRun execution message
203+
expect(cleanStdout).toContain('DryRun execution of:');
204+
expect(cleanStdout).toContain('npx @code-pushup/cli');
204205
expect(cleanStdout).toContain('--dryRun --verbose');
205206
});
206207

packages/utils/src/lib/execute-process.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export function executeProcess(cfg: ProcessConfig): Promise<ProcessResult> {
164164
const spawnedProcess = spawn(command, args ?? [], {
165165
// shell:true tells Windows to use shell command for spawning a child process
166166
// https://stackoverflow.com/questions/60386867/node-spawn-child-process-not-working-in-windows
167-
shell: true,
167+
// Note: When shell is true, args are passed as-is to the shell
168+
shell: process.platform === 'win32',
168169
windowsHide: true,
169170
...options,
170171
}) as ChildProcessByStdio<Writable, Readable, Readable>;

0 commit comments

Comments
 (0)