chore: fix other tests

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2023-01-11 14:07:02 +01:00
parent 54632b8304
commit 8c19b84088
5 changed files with 5 additions and 38 deletions
@@ -17,18 +17,14 @@
import mockFs from 'mock-fs';
import { resolve as resolvePath } from 'path';
import fetch from 'node-fetch';
import { coreServices } from '@backstage/backend-plugin-api';
import { startTestBackend } from '@backstage/backend-test-utils';
import { appPlugin } from './appPlugin';
import {
databaseFactory,
httpRouterFactory,
rootHttpRouterFactory,
loggerFactory,
rootLoggerFactory,
} from '@backstage/backend-app-api';
import { ConfigReader } from '@backstage/config';
import getPort from 'get-port';
describe('appPlugin', () => {
beforeEach(() => {
@@ -48,23 +44,12 @@ describe('appPlugin', () => {
});
it('boots', async () => {
const port = await getPort();
await startTestBackend({
const { server } = await startTestBackend({
services: [
[
coreServices.config,
new ConfigReader({
backend: {
listen: { port },
database: { client: 'better-sqlite3', connection: ':memory:' },
},
}),
],
loggerFactory(),
rootLoggerFactory(),
databaseFactory(),
httpRouterFactory(),
rootHttpRouterFactory(),
],
features: [
appPlugin({
@@ -75,12 +60,12 @@ describe('appPlugin', () => {
});
await expect(
fetch(`http://localhost:${port}/api/app/derp.html`).then(res =>
fetch(`http://localhost:${server.port()}/api/app/derp.html`).then(res =>
res.text(),
),
).resolves.toBe('winning');
await expect(
fetch(`http://localhost:${port}`).then(res => res.text()),
fetch(`http://localhost:${server.port()}`).then(res => res.text()),
).resolves.toBe('winning');
});
});