diff --git a/tests/integration/commands/dev/edge-functions.test.ts b/tests/integration/commands/dev/edge-functions.test.ts index f793377014a..1b3b1295b7e 100644 --- a/tests/integration/commands/dev/edge-functions.test.ts +++ b/tests/integration/commands/dev/edge-functions.test.ts @@ -47,7 +47,7 @@ const setupInternalEdgeFunctions = async ({ fixture }: FixtureTestContext) => { describe.skipIf(isWindows)('edge functions', () => { setupFixtureTests( 'dev-server-with-edge-functions', - { devServer: true, mockApi: { routes }, setup: setupInternalEdgeFunctions }, + { devServer: true, mockApi: { routes }, setupDev: setupInternalEdgeFunctions }, () => { test('should run edge functions in correct order', async ({ devServer }) => { const response = await got(`http://localhost:${devServer.port}/ordertest`, { diff --git a/tests/integration/utils/dev-server.ts b/tests/integration/utils/dev-server.ts index fdbaecdb9f0..f7d9c46ee98 100644 --- a/tests/integration/utils/dev-server.ts +++ b/tests/integration/utils/dev-server.ts @@ -22,7 +22,7 @@ export const getExecaOptions = ({ cwd, env }) => { } } -interface DevServer { +export interface DevServer { url: string host: string port: number diff --git a/tests/integration/utils/fixture.ts b/tests/integration/utils/fixture.ts index 763ee9bcf17..71ff5d21c90 100644 --- a/tests/integration/utils/fixture.ts +++ b/tests/integration/utils/fixture.ts @@ -7,7 +7,7 @@ import { temporaryDirectory } from 'tempy' import { afterAll, afterEach, beforeAll, beforeEach, describe } from 'vitest' import { callCli } from './call-cli.js' -import { startDevServer } from './dev-server.ts' +import { DevServer, startDevServer } from './dev-server.ts' import { MockApi, Route, getCLIOptions, startMockApi } from './mock-api-vitest.js' import { SiteBuilder } from './site-builder.ts' @@ -20,7 +20,7 @@ interface MockApiOptions { export interface FixtureTestContext { fixture: Fixture - devServer?: any + devServer?: DevServer mockApi?: MockApi } @@ -33,6 +33,10 @@ export interface FixtureOptions { * Executed after fixture setup, but before tests run */ setup?: LifecycleHook + /** + * Executed after fixture setup, after dev server was started, but before tests run + */ + setupDev?: LifecycleHook /** * Executed before fixture is cleaned up */ @@ -136,7 +140,7 @@ export async function setupFixtureTests( } describe(`fixture: ${fixturePath}`, async () => { - let devServer: any + let devServer: DevServer let mockApi: MockApi | undefined let fixture: Fixture @@ -144,6 +148,8 @@ export async function setupFixtureTests( if (options.mockApi) mockApi = await startMockApi(options.mockApi) fixture = await Fixture.create(fixturePath, { apiUrl: mockApi?.apiUrl }) + await options.setup?.({ fixture, mockApi }) + if (options.devServer) { devServer = await startDevServer({ serve: typeof options.devServer === 'object' && options.devServer.serve, @@ -156,9 +162,9 @@ export async function setupFixtureTests( NETLIFY_AUTH_TOKEN: 'fake-token', }, }) - } - await options.setup?.({ fixture, mockApi }) + await options.setupDev?.({ fixture, mockApi, devServer }) + } }, HOOK_TIMEOUT) beforeEach((context) => {