Skip to content

Commit

Permalink
fix(testing): target defaults migration should not throw if workspace…
Browse files Browse the repository at this point in the history
… contains inferred projects (#20189)

(cherry picked from commit fec681b)
  • Loading branch information
AgentEnder authored and FrozenPandaz committed Nov 13, 2023
1 parent 444ae34 commit b8fe86d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -559,4 +559,46 @@ describe('move-options-to-target-defaults migration', () => {
},
});
});

it("should't error if a project is present in the graph but not using project.json", async () => {
projectGraph.nodes['csproj'] = {
name: 'csproj',
type: 'lib',
data: {
root: 'csproj',
targets: {
build: {
command: 'echo HELLO',
},
},
},
};
addProjectConfiguration(tree, 'proj1', {
root: 'proj1',
targets: {
test: {
executor: '@nx/jest:jest',
options: {
jestConfig: 'jest.config.js',
passWithNoTests: true,
},
configurations: {
ci: {
ci: true,
codeCoverage: true,
},
},
},
},
});
updateNxJson(tree, {
targetDefaults: {
build: {
inputs: ['default', '^production'],
},
},
});
const promise = update(tree);
await expect(promise).resolves.not.toThrow();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function isTargetDefaultUsed(
targetName,
targetDefaults,
// It might seem like we should use the graph here too but we don't want to pass an executor which was processed in the graph
projectMap.get(p.name).targets?.[targetName]?.executor
projectMap.get(p.name)?.targets?.[targetName]?.executor
) === targetDefault
) {
return true;
Expand Down

0 comments on commit b8fe86d

Please sign in to comment.