Skip to content

Commit 4438207

Browse files
committed
fix(testing): update jest plugin to forward top level args for ci target
1 parent a1e0d3c commit 4438207

File tree

2 files changed

+54
-30
lines changed

2 files changed

+54
-30
lines changed

packages/jest/src/plugins/plugin.spec.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ describe.each([true, false])('@nx/jest/plugin', (disableJestRuntime) => {
189189
"test-ci": {
190190
"cache": true,
191191
"dependsOn": [
192-
"test-ci--src/unit.spec.ts",
192+
{
193+
"params": "forward",
194+
"projects": "self",
195+
"target": "test-ci--src/unit.spec.ts",
196+
},
193197
],
194198
"executor": "nx:noop",
195199
"inputs": [
@@ -492,7 +496,11 @@ describe.each([true, false])('@nx/jest/plugin', (disableJestRuntime) => {
492496
"test-ci": {
493497
"cache": true,
494498
"dependsOn": [
495-
"test-ci--src/unit.spec.ts",
499+
{
500+
"params": "forward",
501+
"projects": "self",
502+
"target": "test-ci--src/unit.spec.ts",
503+
},
496504
],
497505
"executor": "nx:noop",
498506
"inputs": [
@@ -642,7 +650,11 @@ describe.each([true, false])('@nx/jest/plugin', (disableJestRuntime) => {
642650
"test-ci": {
643651
"cache": true,
644652
"dependsOn": [
645-
"test-ci--src/unit.spec.ts",
653+
{
654+
"params": "forward",
655+
"projects": "self",
656+
"target": "test-ci--src/unit.spec.ts",
657+
},
646658
],
647659
"executor": "nx:noop",
648660
"inputs": [
@@ -792,7 +804,11 @@ describe.each([true, false])('@nx/jest/plugin', (disableJestRuntime) => {
792804
"testci": {
793805
"cache": true,
794806
"dependsOn": [
795-
"testci--src/unit.spec.ts",
807+
{
808+
"params": "forward",
809+
"projects": "self",
810+
"target": "testci--src/unit.spec.ts",
811+
},
796812
],
797813
"executor": "nx:noop",
798814
"inputs": [

packages/jest/src/plugins/plugin.ts

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ async function buildJestTargets(
317317
presetCache
318318
);
319319
const targetGroup = [];
320-
const dependsOn: string[] = [];
320+
const dependsOn: TargetConfiguration['dependsOn'] = [];
321321
metadata = {
322322
targetGroups: {
323323
[groupName]: targetGroup,
@@ -339,7 +339,12 @@ async function buildJestTargets(
339339
}
340340

341341
const targetName = `${options.ciTargetName}--${relativePath}`;
342-
dependsOn.push(targetName);
342+
dependsOn.push({
343+
target: targetName,
344+
projects: 'self',
345+
params: 'forward',
346+
});
347+
343348
targets[targetName] = {
344349
command: `jest ${relativePath}`,
345350
cache,
@@ -450,36 +455,18 @@ async function buildJestTargets(
450455
[groupName]: targetGroup,
451456
},
452457
};
453-
const dependsOn: string[] = [];
454-
455-
targets[options.ciTargetName] = {
456-
executor: 'nx:noop',
457-
cache: true,
458-
inputs,
459-
outputs,
460-
dependsOn,
461-
metadata: {
462-
technologies: ['jest'],
463-
description: 'Run Jest Tests in CI',
464-
nonAtomizedTarget: options.targetName,
465-
help: {
466-
command: `${pmc.exec} jest --help`,
467-
example: {
468-
options: {
469-
coverage: true,
470-
},
471-
},
472-
},
473-
},
474-
};
475-
targetGroup.push(options.ciTargetName);
458+
const dependsOn: TargetConfiguration['dependsOn'] = [];
476459

477460
for (const testPath of testPaths) {
478461
const relativePath = normalizePath(
479462
relative(join(context.workspaceRoot, projectRoot), testPath)
480463
);
481464
const targetName = `${options.ciTargetName}--${relativePath}`;
482-
dependsOn.push(targetName);
465+
dependsOn.push({
466+
target: targetName,
467+
projects: 'self',
468+
params: 'forward',
469+
});
483470
targets[targetName] = {
484471
command: `jest ${relativePath}`,
485472
cache,
@@ -504,6 +491,27 @@ async function buildJestTargets(
504491
};
505492
targetGroup.push(targetName);
506493
}
494+
targets[options.ciTargetName] = {
495+
executor: 'nx:noop',
496+
cache: true,
497+
inputs,
498+
outputs,
499+
dependsOn,
500+
metadata: {
501+
technologies: ['jest'],
502+
description: 'Run Jest Tests in CI',
503+
nonAtomizedTarget: options.targetName,
504+
help: {
505+
command: `${pmc.exec} jest --help`,
506+
example: {
507+
options: {
508+
coverage: true,
509+
},
510+
},
511+
},
512+
},
513+
};
514+
targetGroup.unshift(options.ciTargetName);
507515
}
508516
}
509517
}

0 commit comments

Comments
 (0)