backend-test-utils: fix handling of root scoped services

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: Johan Haals <johan.haals@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-09-26 16:18:05 +02:00
parent 45857bffae
commit 72549952d1
2 changed files with 15 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-test-utils': patch
---
Fixed handling of root scoped services in `startTestBackend`.
@@ -63,10 +63,18 @@ export async function startTestBackend<
if (Array.isArray(serviceDef)) {
// if type is ExtensionPoint?
// do something differently?
const [ref, impl] = serviceDef;
if (ref.scope === 'plugin') {
return createServiceFactory({
service: ref,
deps: {},
factory: async () => async () => impl,
});
}
return createServiceFactory({
service: serviceDef[0],
service: ref,
deps: {},
factory: async () => async () => serviceDef[1],
factory: async () => impl,
});
}
return serviceDef as ServiceFactory;