diff --git a/packages/core-api/src/app/App.tsx b/packages/core-api/src/app/App.tsx index 49d2291acd..4207a267af 100644 --- a/packages/core-api/src/app/App.tsx +++ b/packages/core-api/src/app/App.tsx @@ -43,7 +43,7 @@ type FullAppOptions = { plugins: BackstagePlugin[]; components: AppComponents; themes: AppTheme[]; - configLoader: AppConfigLoader; + configLoader?: AppConfigLoader; }; export class PrivateAppImpl implements BackstageApp { @@ -52,7 +52,7 @@ export class PrivateAppImpl implements BackstageApp { private readonly plugins: BackstagePlugin[]; private readonly components: AppComponents; private readonly themes: AppTheme[]; - private readonly configLoader: AppConfigLoader; + private readonly configLoader?: AppConfigLoader; constructor(options: FullAppOptions) { this.apis = options.apis; @@ -148,11 +148,13 @@ export class PrivateAppImpl implements BackstageApp { getProvider(): ComponentType<{}> { const Provider: FC<{}> = ({ children }) => { - const config = useAsync(this.configLoader); + // Keeping this synchronous when a config loader isn't set simplifies tests a lot + const hasConfig = Boolean(this.configLoader); + const config = useAsync(this.configLoader || (() => Promise.resolve({}))); let childNode = children; - if (config.loading) { + if (hasConfig && config.loading) { const { Progress } = this.components; childNode = ; } else if (config.error) { diff --git a/packages/test-utils/src/testUtils/appWrappers.tsx b/packages/test-utils/src/testUtils/appWrappers.tsx index 7849ed20cc..2450604976 100644 --- a/packages/test-utils/src/testUtils/appWrappers.tsx +++ b/packages/test-utils/src/testUtils/appWrappers.tsx @@ -66,7 +66,6 @@ export function wrapInTestApp( variant: 'light', }, ], - configLoader: async () => ({}), }); let Wrapper: ComponentType;