fix(cli): add helpful error message for missing jest dependency
Since jest is now a peer dependencies, users must add it as a devDependency themselves. This commit adds early detection and a helpful error message when jest is missing, directing users to the migration guide. Signed-off-by: Johan Persson <johanopersson@gmail.com>
This commit is contained in:
@@ -83,5 +83,23 @@ export default async (_opts: OptionValues, cmd: Command) => {
|
||||
(process.stdout as any)._handle.setBlocking(true);
|
||||
}
|
||||
|
||||
// Because of the ongoing migration to v30 of jest, jest is no longer hard-depended to allow
|
||||
// opt-in migration. Users instead need to add jest as a devDependency themselves and specify
|
||||
// the version they want. This prints a helpful error message if jest is not found, i.e. they
|
||||
// forgot/didn't know they had to add jest themselves.
|
||||
try {
|
||||
require.resolve('jest');
|
||||
} catch {
|
||||
console.error(
|
||||
[
|
||||
'No Jest installation found in this project.',
|
||||
'',
|
||||
'To support opt-in migration to Jest v30, the Backstage CLI now expects Jest to be installed as a devDependency.',
|
||||
'See the migration guide in the changelog for version options and their consequences.',
|
||||
].join('\n'),
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await require('jest').run(args);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user