Skip to content

Commit ed75f3c

Browse files
author
John Doe
committed
refactor: wip
1 parent 5219bea commit ed75f3c

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ async function addTargetToWorkspace(
2727
) {
2828
const { cwd, project } = options;
2929
const projectCfg = readProjectConfiguration(tree, project);
30+
const { root } = projectCfg;
31+
const configPath = path.join(root, 'code-pushup.config.ts');
3032
updateProjectConfiguration(tree, project, {
3133
...projectCfg,
3234
targets: {
3335
...projectCfg.targets,
3436
'code-pushup': {
3537
executor: '@code-pushup/nx-plugin:cli',
36-
...(executorOptions && { options: executorOptions }),
38+
options: {
39+
config: configPath,
40+
...executorOptions,
41+
},
3742
},
3843
},
3944
});
40-
const { root } = projectCfg;
4145
generateCodePushupConfig(tree, root, {
4246
plugins: [
4347
{
@@ -144,7 +148,7 @@ describe('executor command', () => {
144148
).resolves.not.toThrow();
145149
});
146150

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

@@ -156,6 +160,9 @@ describe('executor command', () => {
156160
`${project}:code-pushup`,
157161
'print-config',
158162
'--upload.apiKey=a123a',
163+
'--upload.server=https://example.com',
164+
'--upload.organization=test-org',
165+
'--upload.project=test-project',
159166
],
160167
cwd,
161168
});
@@ -203,9 +210,15 @@ describe('executor command', () => {
203210
);
204211
expect(cleanStdout).toContain('Code PushUp CLI');
205212

206-
await expect(
207-
readJsonFile(path.join(cwd, '.reports', 'terminal-report.json')),
208-
).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();
209222
});
210223

211224
it('should execute collect executor and add report to sub folder named by project', async () => {
@@ -223,7 +236,7 @@ describe('executor command', () => {
223236
expect(cleanStdout).toContain('nx run my-lib:code-pushup collect');
224237

225238
const report = await readJsonFile(
226-
path.join(cwd, '.code-pushup', project, 'report.json'),
239+
path.join(cwd, 'libs', project, '.code-pushup', 'report.json'),
227240
);
228241
expect(report).toStrictEqual(
229242
expect.objectContaining({

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe('nx-plugin', () => {
2929
TEST_OUTPUT_DIR,
3030
'plugin-create-nodes',
3131
);
32+
const PACKAGE_NAME = '@code-pushup/nx-plugin';
3233

3334
beforeEach(async () => {
3435
tree = await generateWorkspaceAndProject(project);
@@ -120,7 +121,7 @@ describe('nx-plugin', () => {
120121
expect(projectJson.targets).toStrictEqual({
121122
'code-pushup--configuration': expect.objectContaining({
122123
options: {
123-
command: `nx g XYZ:configuration --project="${project}"`,
124+
command: `nx g ${PACKAGE_NAME}:configuration --project="${project}"`,
124125
},
125126
}),
126127
});
@@ -198,8 +199,9 @@ describe('nx-plugin', () => {
198199
const cleanStdout = removeColorCodes(stdout);
199200
// Nx command
200201
expect(cleanStdout).toContain('nx run my-lib:code-pushup');
201-
// Run CLI executor
202-
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');
203205
expect(cleanStdout).toContain('--dryRun --verbose');
204206
});
205207

0 commit comments

Comments
 (0)