@backstage/backend-test-utils 0.4.4-next.1 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -7,7 +7,6 @@ import { ServiceFactory, ServiceRef, ExtensionPoint, BackendFeature, RootConfigS
7
7
  import { Backend, ExtendedHttpServer } from '@backstage/backend-app-api';
8
8
  import * as _backstage_plugin_events_node from '@backstage/plugin-events-node';
9
9
  import * as _backstage_backend_defaults_rootHttpRouter from '@backstage/backend-defaults/rootHttpRouter';
10
- import * as _backstage_backend_defaults_httpRouter from '@backstage/backend-defaults/httpRouter';
11
10
  import { JsonObject } from '@backstage/types';
12
11
 
13
12
  /**
@@ -201,6 +200,20 @@ declare function createMockDirectory(options?: CreateMockDirectoryOptions): Mock
201
200
  * @deprecated Use `CreateMockDirectoryOptions` from `@backstage/backend-test-utils` instead.
202
201
  */
203
202
  type MockDirectoryOptions = CreateMockDirectoryOptions;
203
+ /**
204
+ * @public
205
+ * @deprecated Use `registerMswTestHooks` from `@backstage/backend-test-utils` instead.
206
+ */
207
+ declare function setupRequestMockHandlers(worker: {
208
+ listen: (t: any) => void;
209
+ close: () => void;
210
+ resetHandlers: () => void;
211
+ }): void;
212
+ /**
213
+ * @public
214
+ * @deprecated This is an internal function and will no longer be exported from this package.
215
+ */
216
+ declare function isDockerDisabledForTests(): boolean;
204
217
 
205
218
  /**
206
219
  * The possible caches to test against.
@@ -311,7 +324,7 @@ declare class TestDatabases {
311
324
  * @public
312
325
  * @param worker - service worker
313
326
  */
314
- declare function setupRequestMockHandlers(worker: {
327
+ declare function registerMswTestHooks(worker: {
315
328
  listen: (t: any) => void;
316
329
  close: () => void;
317
330
  resetHandlers: () => void;
@@ -330,7 +343,7 @@ interface ServiceFactoryTesterOptions {
330
343
  * If a service factory is provided for a service that already has a default
331
344
  * implementation, the provided factory will override the default.
332
345
  */
333
- dependencies?: Array<ServiceFactory | (() => ServiceFactory)>;
346
+ dependencies?: Array<ServiceFactory>;
334
347
  }
335
348
  /**
336
349
  * A utility to help test service factories in isolation.
@@ -346,8 +359,14 @@ declare class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
346
359
  * @param options - Additional options
347
360
  * @returns A new tester instance for the provided subject.
348
361
  */
349
- static from<TService, TScope extends 'root' | 'plugin'>(subject: ServiceFactory<TService, TScope> | (() => ServiceFactory<TService, TScope>), options?: ServiceFactoryTesterOptions): ServiceFactoryTester<TService, TScope>;
362
+ static from<TService, TScope extends 'root' | 'plugin'>(subject: ServiceFactory<TService, TScope>, options?: ServiceFactoryTesterOptions): ServiceFactoryTester<TService, TScope>;
350
363
  private constructor();
364
+ /**
365
+ * Returns the service instance for the subject.
366
+ *
367
+ * @deprecated Use `getSubject` instead.
368
+ */
369
+ get(...args: 'root' extends TScope ? [] : [pluginId?: string]): Promise<TService>;
351
370
  /**
352
371
  * Returns the service instance for the subject.
353
372
  *
@@ -358,7 +377,7 @@ declare class ServiceFactoryTester<TService, TScope extends 'root' | 'plugin'> {
358
377
  *
359
378
  * By default the plugin ID 'test' is used.
360
379
  */
361
- get(...args: 'root' extends TScope ? [] : [pluginId?: string]): Promise<TService>;
380
+ getSubject(...args: 'root' extends TScope ? [] : [pluginId?: string]): Promise<TService>;
362
381
  /**
363
382
  * Return the service instance for any of the provided dependencies or built-in services.
364
383
  *
@@ -379,8 +398,8 @@ interface TestBackendOptions<TExtensionPoints extends any[]> {
379
398
  ];
380
399
  }
381
400
  ];
382
- features?: Array<BackendFeature | (() => BackendFeature) | Promise<{
383
- default: BackendFeature | (() => BackendFeature);
401
+ features?: Array<BackendFeature | Promise<{
402
+ default: BackendFeature;
384
403
  }>>;
385
404
  }
386
405
  /** @public */
@@ -411,24 +430,24 @@ declare namespace mockServices {
411
430
  type Options = {
412
431
  data?: JsonObject;
413
432
  };
414
- const factory: (options?: Options | undefined) => ServiceFactory<RootConfigService, "root">;
433
+ const factory: ServiceFactory<RootConfigService, "root"> & ((options?: Options | undefined) => ServiceFactory<RootConfigService, "root">);
415
434
  }
416
435
  function rootLogger(options?: rootLogger.Options): LoggerService;
417
436
  namespace rootLogger {
418
437
  type Options = {
419
438
  level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
420
439
  };
421
- const factory: (options?: Options | undefined) => ServiceFactory<LoggerService, "root">;
440
+ const factory: ServiceFactory<LoggerService, "root"> & ((options?: Options | undefined) => ServiceFactory<LoggerService, "root">);
422
441
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootLoggerService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootLoggerService>;
423
442
  }
424
443
  function tokenManager(): TokenManagerService;
425
444
  namespace tokenManager {
426
- const factory: () => ServiceFactory<TokenManagerService, "plugin">;
445
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<TokenManagerService, "plugin", undefined>;
427
446
  const mock: (partialImpl?: Partial<TokenManagerService> | undefined) => ServiceMock<TokenManagerService>;
428
447
  }
429
448
  function identity(): IdentityService;
430
449
  namespace identity {
431
- const factory: () => ServiceFactory<IdentityService, "plugin">;
450
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<IdentityService, "plugin", undefined>;
432
451
  const mock: (partialImpl?: Partial<IdentityService> | undefined) => ServiceMock<IdentityService>;
433
452
  }
434
453
  function auth(options?: {
@@ -436,12 +455,12 @@ declare namespace mockServices {
436
455
  disableDefaultAuthPolicy?: boolean;
437
456
  }): AuthService;
438
457
  namespace auth {
439
- const factory: () => ServiceFactory<AuthService, "plugin">;
458
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<AuthService, "plugin", undefined>;
440
459
  const mock: (partialImpl?: Partial<AuthService> | undefined) => ServiceMock<AuthService>;
441
460
  }
442
461
  function discovery(): DiscoveryService;
443
462
  namespace discovery {
444
- const factory: () => ServiceFactory<DiscoveryService, "plugin">;
463
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<DiscoveryService, "plugin", undefined>;
445
464
  const mock: (partialImpl?: Partial<DiscoveryService> | undefined) => ServiceMock<DiscoveryService>;
446
465
  }
447
466
  /**
@@ -470,9 +489,9 @@ declare namespace mockServices {
470
489
  * the default mock user principal. This behavior can be configured with the
471
490
  * `defaultCredentials` option.
472
491
  */
473
- const factory: (options?: {
474
- defaultCredentials?: BackstageCredentials | undefined;
475
- } | undefined) => ServiceFactory<HttpAuthService, "plugin">;
492
+ const factory: ((options?: {
493
+ defaultCredentials?: BackstageCredentials;
494
+ }) => ServiceFactory<HttpAuthService, "plugin">) & ServiceFactory<HttpAuthService, "plugin">;
476
495
  const mock: (partialImpl?: Partial<HttpAuthService> | undefined) => ServiceMock<HttpAuthService>;
477
496
  }
478
497
  /**
@@ -490,55 +509,55 @@ declare namespace mockServices {
490
509
  * By default it extracts the user's entity ref from a user principal and
491
510
  * returns that as the only ownership entity ref.
492
511
  */
493
- const factory: () => ServiceFactory<UserInfoService, "plugin">;
512
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<UserInfoService, "plugin", undefined>;
494
513
  const mock: (partialImpl?: Partial<UserInfoService> | undefined) => ServiceMock<UserInfoService>;
495
514
  }
496
515
  namespace cache {
497
- const factory: () => ServiceFactory<_backstage_backend_plugin_api.CacheService, "plugin">;
516
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.CacheService, "plugin", undefined>;
498
517
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.CacheService> | undefined) => ServiceMock<_backstage_backend_plugin_api.CacheService>;
499
518
  }
500
519
  namespace database {
501
- const factory: () => ServiceFactory<_backstage_backend_plugin_api.DatabaseService, "plugin">;
520
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.DatabaseService, "plugin", undefined>;
502
521
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.DatabaseService> | undefined) => ServiceMock<_backstage_backend_plugin_api.DatabaseService>;
503
522
  }
504
523
  namespace rootHealth {
505
- const factory: () => ServiceFactory<_backstage_backend_plugin_api.RootHealthService, "root">;
524
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.RootHealthService, "root", undefined>;
506
525
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootHealthService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootHealthService>;
507
526
  }
508
527
  namespace httpRouter {
509
- const factory: (options?: _backstage_backend_defaults_httpRouter.HttpRouterFactoryOptions | undefined) => ServiceFactory<_backstage_backend_plugin_api.HttpRouterService, "plugin">;
528
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.HttpRouterService, "plugin", undefined>;
510
529
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.HttpRouterService> | undefined) => ServiceMock<_backstage_backend_plugin_api.HttpRouterService>;
511
530
  }
512
531
  namespace rootHttpRouter {
513
- const factory: (options?: _backstage_backend_defaults_rootHttpRouter.RootHttpRouterFactoryOptions | undefined) => ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root">;
532
+ const factory: ((options?: _backstage_backend_defaults_rootHttpRouter.RootHttpRouterFactoryOptions | undefined) => ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root">) & ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root">;
514
533
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootHttpRouterService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootHttpRouterService>;
515
534
  }
516
535
  namespace lifecycle {
517
- const factory: () => ServiceFactory<_backstage_backend_plugin_api.LifecycleService, "plugin">;
536
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.LifecycleService, "plugin", undefined>;
518
537
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.LifecycleService> | undefined) => ServiceMock<_backstage_backend_plugin_api.LifecycleService>;
519
538
  }
520
539
  namespace logger {
521
- const factory: () => ServiceFactory<LoggerService, "plugin">;
540
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<LoggerService, "plugin", undefined>;
522
541
  const mock: (partialImpl?: Partial<LoggerService> | undefined) => ServiceMock<LoggerService>;
523
542
  }
524
543
  namespace permissions {
525
- const factory: () => ServiceFactory<_backstage_backend_plugin_api.PermissionsService, "plugin">;
544
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.PermissionsService, "plugin", undefined>;
526
545
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.PermissionsService> | undefined) => ServiceMock<_backstage_backend_plugin_api.PermissionsService>;
527
546
  }
528
547
  namespace rootLifecycle {
529
- const factory: () => ServiceFactory<_backstage_backend_plugin_api.RootLifecycleService, "root">;
548
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.RootLifecycleService, "root", undefined>;
530
549
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootLifecycleService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootLifecycleService>;
531
550
  }
532
551
  namespace scheduler {
533
- const factory: () => ServiceFactory<_backstage_backend_plugin_api.SchedulerService, "plugin">;
552
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.SchedulerService, "plugin", undefined>;
534
553
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.SchedulerService> | undefined) => ServiceMock<_backstage_backend_plugin_api.SchedulerService>;
535
554
  }
536
555
  namespace urlReader {
537
- const factory: () => ServiceFactory<_backstage_backend_plugin_api.UrlReaderService, "plugin">;
556
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_backend_plugin_api.UrlReaderService, "plugin", undefined>;
538
557
  const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.UrlReaderService> | undefined) => ServiceMock<_backstage_backend_plugin_api.UrlReaderService>;
539
558
  }
540
559
  namespace events {
541
- const factory: () => ServiceFactory<_backstage_plugin_events_node.EventsService, "plugin">;
560
+ const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<_backstage_plugin_events_node.EventsService, "plugin", undefined>;
542
561
  const mock: (partialImpl?: Partial<_backstage_plugin_events_node.EventsService> | undefined) => ServiceMock<_backstage_plugin_events_node.EventsService>;
543
562
  }
544
563
  }
@@ -650,7 +669,4 @@ declare namespace mockCredentials {
650
669
  }
651
670
  }
652
671
 
653
- /** @public */
654
- declare function isDockerDisabledForTests(): boolean;
655
-
656
- export { type CreateMockDirectoryOptions, type MockDirectory, type MockDirectoryContent, type MockDirectoryContentCallback, type MockDirectoryContentCallbackContext, type MockDirectoryContentOptions, type MockDirectoryOptions, ServiceFactoryTester, type ServiceFactoryTesterOptions, type ServiceMock, type TestBackend, type TestBackendOptions, type TestCacheId, TestCaches, type TestDatabaseId, TestDatabases, createMockDirectory, isDockerDisabledForTests, mockCredentials, mockServices, setupRequestMockHandlers, startTestBackend };
672
+ export { type CreateMockDirectoryOptions, type MockDirectory, type MockDirectoryContent, type MockDirectoryContentCallback, type MockDirectoryContentCallbackContext, type MockDirectoryContentOptions, type MockDirectoryOptions, ServiceFactoryTester, type ServiceFactoryTesterOptions, type ServiceMock, type TestBackend, type TestBackendOptions, type TestCacheId, TestCaches, type TestDatabaseId, TestDatabases, createMockDirectory, isDockerDisabledForTests, mockCredentials, mockServices, registerMswTestHooks, setupRequestMockHandlers, startTestBackend };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-test-utils",
3
- "version": "0.4.4-next.1",
3
+ "version": "0.4.4",
4
4
  "description": "Test helpers library for Backstage backends",
5
5
  "backstage": {
6
6
  "role": "node-library"
@@ -42,13 +42,13 @@
42
42
  "test": "backstage-cli package test"
43
43
  },
44
44
  "dependencies": {
45
- "@backstage/backend-app-api": "^0.7.10-next.1",
46
- "@backstage/backend-defaults": "^0.3.4-next.1",
47
- "@backstage/backend-plugin-api": "^0.6.22-next.1",
45
+ "@backstage/backend-app-api": "^0.8.0",
46
+ "@backstage/backend-defaults": "^0.4.0",
47
+ "@backstage/backend-plugin-api": "^0.7.0",
48
48
  "@backstage/config": "^1.2.0",
49
49
  "@backstage/errors": "^1.2.4",
50
- "@backstage/plugin-auth-node": "^0.4.17-next.1",
51
- "@backstage/plugin-events-node": "^0.3.8-next.1",
50
+ "@backstage/plugin-auth-node": "^0.4.17",
51
+ "@backstage/plugin-events-node": "^0.3.8",
52
52
  "@backstage/types": "^1.1.1",
53
53
  "@keyv/memcache": "^1.3.5",
54
54
  "@keyv/redis": "^2.5.3",
@@ -69,7 +69,7 @@
69
69
  "yn": "^4.0.0"
70
70
  },
71
71
  "devDependencies": {
72
- "@backstage/cli": "^0.26.11-next.1",
72
+ "@backstage/cli": "^0.26.11",
73
73
  "@types/supertest": "^2.0.8",
74
74
  "supertest": "^6.1.3"
75
75
  },