Skip to content

Commit 4f31608

Browse files
authored
fix(core): workspace remove generator should handle no root jest config (#23328)
1 parent 7561e71 commit 4f31608

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/workspace/src/generators/remove/lib/update-jest-config.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,24 @@ describe('updateRootJestConfig', () => {
9191

9292
expect(rootJestConfig).toMatchSnapshot();
9393
});
94+
95+
it('should handle not having a root jest config file', async () => {
96+
// ARRANGE
97+
tree.delete('jest.config.ts');
98+
99+
await libraryGenerator(tree, {
100+
name: 'test',
101+
bundler: 'vite',
102+
unitTestRunner: 'vitest',
103+
});
104+
105+
// ACT
106+
expect(() =>
107+
updateJestConfig(
108+
tree,
109+
{ projectName: 'test', skipFormat: false, forceRemove: false },
110+
readProjectConfiguration(tree, 'test')
111+
)
112+
).not.toThrow();
113+
});
94114
});

packages/workspace/src/generators/remove/lib/update-jest-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export function updateJestConfig(
6969
const rootConfigPath = findRootJestConfig(tree);
7070

7171
if (
72+
!rootConfigPath ||
7273
!tree.exists(rootConfigPath) ||
7374
!tree.exists(join(projectConfig.root, 'jest.config.ts')) ||
7475
isUsingUtilityFunction(tree) ||

0 commit comments

Comments
 (0)