@backstage/backend-test-utils 0.4.5-next.3 → 0.5.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @backstage/backend-test-utils
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 861f162: **BREAKING**: Removed these deprecated helpers:
8
+
9
+ - `setupRequestMockHandlers` Use `CreateMockDirectoryOptions` instead.
10
+ - `CreateMockDirectoryOptions` Use `registerMswTestHooks` instead.
11
+
12
+ Stopped exporting the deprecated and internal `isDockerDisabledForTests` helper.
13
+
14
+ Removed `get` method from `ServiceFactoryTester` which is replaced by `getSubject`
15
+
16
+ ### Patch Changes
17
+
18
+ - 8b13183: Internal updates to support latest version of `BackendFeauture`s from `@backstage/backend-plugin-api`.
19
+ - b63d378: Update internal imports
20
+ - 7c5f3b0: Update the `ServiceFactoryTester` to be able to test services that enables multi implementation installation.
21
+ - 4e79d19: The default services for `startTestBackend` and `ServiceFactoryTester` now includes the Root Health Service.
22
+ - Updated dependencies
23
+ - @backstage/backend-defaults@0.4.2
24
+ - @backstage/backend-app-api@0.9.0
25
+ - @backstage/backend-plugin-api@0.8.0
26
+ - @backstage/plugin-auth-node@0.5.0
27
+ - @backstage/config@1.2.0
28
+ - @backstage/errors@1.2.4
29
+ - @backstage/types@1.1.1
30
+ - @backstage/plugin-events-node@0.3.9
31
+
3
32
  ## 0.4.5-next.3
4
33
 
5
34
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -44,21 +44,8 @@ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
44
44
  var textextensions__default = /*#__PURE__*/_interopDefaultCompat(textextensions);
45
45
  var express__default = /*#__PURE__*/_interopDefaultCompat(express);
46
46
 
47
- function registerMswTestHooks(worker) {
48
- beforeAll(() => worker.listen({ onUnhandledRequest: "error" }));
49
- afterAll(() => worker.close());
50
- afterEach(() => worker.resetHandlers());
51
- }
52
-
53
- function isDockerDisabledForTests$1() {
54
- return Boolean(process.env.BACKSTAGE_TEST_DISABLE_DOCKER) || !Boolean(process.env.CI);
55
- }
56
-
57
- function setupRequestMockHandlers(worker) {
58
- registerMswTestHooks(worker);
59
- }
60
47
  function isDockerDisabledForTests() {
61
- return isDockerDisabledForTests$1();
48
+ return Boolean(process.env.BACKSTAGE_TEST_DISABLE_DOCKER) || !Boolean(process.env.CI);
62
49
  }
63
50
 
64
51
  async function attemptMemcachedConnection(connection) {
@@ -196,7 +183,7 @@ class TestCaches {
196
183
  */
197
184
  static create(options) {
198
185
  const ids = options?.ids;
199
- const disableDocker = options?.disableDocker ?? isDockerDisabledForTests$1();
186
+ const disableDocker = options?.disableDocker ?? isDockerDisabledForTests();
200
187
  let testCacheIds;
201
188
  if (ids) {
202
189
  testCacheIds = ids;
@@ -733,7 +720,7 @@ class TestDatabases {
733
720
  */
734
721
  static create(options) {
735
722
  const ids = options?.ids;
736
- const disableDocker = options?.disableDocker ?? isDockerDisabledForTests$1();
723
+ const disableDocker = options?.disableDocker ?? isDockerDisabledForTests();
737
724
  let testDatabaseIds;
738
725
  if (ids) {
739
726
  testDatabaseIds = ids;
@@ -827,6 +814,12 @@ class TestDatabases {
827
814
  }
828
815
  }
829
816
 
817
+ function registerMswTestHooks(worker) {
818
+ beforeAll(() => worker.listen({ onUnhandledRequest: "error" }));
819
+ afterAll(() => worker.close());
820
+ afterEach(() => worker.resetHandlers());
821
+ }
822
+
830
823
  const tmpdirMarker = Symbol("os-tmpdir-mock");
831
824
  class MockDirectoryImpl {
832
825
  #root;
@@ -1785,16 +1778,16 @@ async function startTestBackend(options) {
1785
1778
  health: backendPluginApi.coreServices.rootHealth
1786
1779
  },
1787
1780
  async factory({ config, lifecycle, rootLogger, health }) {
1788
- const router = backendAppApi.DefaultRootHttpRouter.create();
1781
+ const router = rootHttpRouter.DefaultRootHttpRouter.create();
1789
1782
  const logger = rootLogger.child({ service: "rootHttpRouter" });
1790
1783
  const app = express__default.default();
1791
- const middleware = backendAppApi.MiddlewareFactory.create({ config, logger });
1784
+ const middleware = rootHttpRouter.MiddlewareFactory.create({ config, logger });
1792
1785
  const healthRouter = rootHttpRouter.createHealthRouter({ health });
1793
1786
  app.use(healthRouter);
1794
1787
  app.use(router.handler());
1795
1788
  app.use(middleware.notFound());
1796
1789
  app.use(middleware.error());
1797
- server = await backendAppApi.createHttpServer(
1790
+ server = await rootHttpRouter.createHttpServer(
1798
1791
  app,
1799
1792
  { listen: { host: "", port: 0 } },
1800
1793
  { logger }
@@ -1814,12 +1807,12 @@ async function startTestBackend(options) {
1814
1807
  throw new Error("Test server not started yet");
1815
1808
  }
1816
1809
  const port = server.port();
1817
- const discovery = backendAppApi.HostDiscovery.fromConfig(
1810
+ const discovery$1 = discovery.HostDiscovery.fromConfig(
1818
1811
  new config.ConfigReader({
1819
1812
  backend: { baseUrl: `http://localhost:${port}`, listen: { port } }
1820
1813
  })
1821
1814
  );
1822
- return discovery;
1815
+ return discovery$1;
1823
1816
  }
1824
1817
  });
1825
1818
  const backend = backendAppApi.createSpecializedBackend({
@@ -2325,14 +2318,6 @@ class ServiceFactoryTester {
2325
2318
  this.#subject = subject;
2326
2319
  this.#registry = registry;
2327
2320
  }
2328
- /**
2329
- * Returns the service instance for the subject.
2330
- *
2331
- * @deprecated Use `getSubject` instead.
2332
- */
2333
- async get(...args) {
2334
- return this.getSubject(...args);
2335
- }
2336
2321
  /**
2337
2322
  * Returns the service instance for the subject.
2338
2323
  *
@@ -2369,8 +2354,6 @@ exports.ServiceFactoryTester = ServiceFactoryTester;
2369
2354
  exports.TestCaches = TestCaches;
2370
2355
  exports.TestDatabases = TestDatabases;
2371
2356
  exports.createMockDirectory = createMockDirectory;
2372
- exports.isDockerDisabledForTests = isDockerDisabledForTests;
2373
2357
  exports.registerMswTestHooks = registerMswTestHooks;
2374
- exports.setupRequestMockHandlers = setupRequestMockHandlers;
2375
2358
  exports.startTestBackend = startTestBackend;
2376
2359
  //# sourceMappingURL=index.cjs.js.map