backend-test-utils: bring back old alpha solution

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-02-10 14:28:03 +01:00
parent 1cedbc7d1b
commit ee8d999aac
5 changed files with 34 additions and 3 deletions
@@ -13,7 +13,6 @@ import { JsonObject } from '@backstage/types';
import { JsonValue } from '@backstage/types';
import { LoggerService } from '@backstage/backend-plugin-api';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import { ServiceMock } from '@backstage/backend-test-utils';
// @alpha (undocumented)
export function actionsRegistryServiceMock(options?: {
@@ -71,5 +70,16 @@ export class MockActionsRegistry
>(options: ActionsRegistryActionOptions<TInputSchema, TOutputSchema>): void;
}
// @public (undocumented)
export type ServiceMock<TService> = {
factory: ServiceFactory<TService>;
} & {
[Key in keyof TService]: TService[Key] extends (
...args: infer Args
) => infer Return
? TService[Key] & jest.MockInstance<Return, Args>
: TService[Key];
};
// (No @packageDocumentation comment for this package)
```
@@ -16,7 +16,7 @@
import { mockServices } from '../../services';
import { LoggerService } from '@backstage/backend-plugin-api';
import { MockActionsRegistry } from './MockActionsRegistry';
import { createServiceMock } from '@backstage/backend-test-utils';
import { createServiceMock } from './alphaCreateServiceMock';
import { actionsRegistryServiceRef } from '@backstage/backend-plugin-api/alpha';
import { actionsRegistryServiceFactory } from '@backstage/backend-defaults/alpha';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { createServiceMock } from '@backstage/backend-test-utils';
import { createServiceMock } from './alphaCreateServiceMock';
import { actionsServiceRef } from '@backstage/backend-plugin-api/alpha';
import { actionsServiceFactory } from '@backstage/backend-defaults/alpha';
@@ -0,0 +1,20 @@
/*
* Copyright 2026 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { createServiceMock } from '../../services/createServiceMock';
/** @alpha */
export type { ServiceMock } from '../../services/createServiceMock';
@@ -17,3 +17,4 @@
export { actionsRegistryServiceMock } from './ActionsRegistryServiceMock';
export { MockActionsRegistry } from './MockActionsRegistry';
export { actionsServiceMock } from './ActionsServiceMock';
export { type ServiceMock } from './alphaCreateServiceMock';