Merge pull request #26365 from backstage/rugvip/throw-test
backend-test-utils: add test to make sure startTestBackend forwards error
This commit is contained in:
@@ -334,4 +334,78 @@ describe('TestBackend', () => {
|
||||
"Unable to determine the plugin ID of extension point(s) 'a'. Tested extension points must be depended on by one or more tested modules.",
|
||||
);
|
||||
});
|
||||
|
||||
it('should forward errors from plugins', async () => {
|
||||
await expect(
|
||||
startTestBackend({
|
||||
features: [
|
||||
createBackendPlugin({
|
||||
pluginId: 'test',
|
||||
register(reg) {
|
||||
reg.registerInit({
|
||||
deps: {},
|
||||
async init() {
|
||||
throw new Error('nah');
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
).rejects.toThrow("Plugin 'test' startup failed; caused by Error: nah");
|
||||
});
|
||||
|
||||
it('should forward errors from modules', async () => {
|
||||
await expect(
|
||||
startTestBackend({
|
||||
features: [
|
||||
createBackendModule({
|
||||
pluginId: 'test',
|
||||
moduleId: 'tester',
|
||||
register(reg) {
|
||||
reg.registerInit({
|
||||
deps: {},
|
||||
async init() {
|
||||
throw new Error('nah');
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
"Module 'tester' for plugin 'test' startup failed; caused by Error: nah",
|
||||
);
|
||||
});
|
||||
|
||||
it('should forward errors from plugin register', async () => {
|
||||
await expect(
|
||||
startTestBackend({
|
||||
features: [
|
||||
createBackendPlugin({
|
||||
pluginId: 'test',
|
||||
register() {
|
||||
throw new Error('nah');
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
).rejects.toThrow('nah');
|
||||
});
|
||||
|
||||
it('should forward errors from module register', async () => {
|
||||
await expect(
|
||||
startTestBackend({
|
||||
features: [
|
||||
createBackendModule({
|
||||
pluginId: 'test',
|
||||
moduleId: 'tester',
|
||||
register() {
|
||||
throw new Error('nah');
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
).rejects.toThrow('nah');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user