|
1 | | -import type { GlobalSetupContext } from 'vitest/node' |
| 1 | +import type { TestProject } from 'vitest/node' |
2 | 2 | import type { NitroInlineConfig } from './config' |
3 | 3 | import { createTestContext } from './context' |
4 | 4 | import { startServer, stopServer } from './server' |
5 | 5 |
|
6 | | -type GlobalSetupContextWithNitro = GlobalSetupContext & { |
| 6 | +type GlobalSetupContextWithNitro = TestProject & { |
7 | 7 | config: { nitro: NitroInlineConfig } |
8 | 8 | } |
9 | 9 |
|
10 | 10 | // Setup shared Nitro instance |
11 | 11 | // See https://vitest.dev/config/#globalsetup |
12 | | -async function setup({ config, provide }: GlobalSetupContextWithNitro): Promise<(() => Promise<void>) | undefined> { |
13 | | - if (!config.nitro.global) |
| 12 | +async function setup(project: GlobalSetupContextWithNitro): Promise<(() => Promise<void>) | undefined> { |
| 13 | + if (!project.config.nitro.global) |
14 | 14 | return |
15 | 15 |
|
16 | 16 | await createTestContext({ |
17 | | - rootDir: config.nitro.global.rootDir || config.root, |
18 | | - mode: config.nitro.global.mode, |
| 17 | + rootDir: project.config.nitro.global.rootDir || project.config.root, |
| 18 | + mode: project.config.nitro.global.mode, |
19 | 19 | isGlobal: true, |
20 | 20 | }) |
21 | 21 |
|
22 | 22 | const ctx = await startServer() |
23 | 23 |
|
24 | 24 | // Global setup is run in a different global scope, so tests don't have access |
25 | 25 | // to variables defined here. We need to expose the server URL for tests. |
26 | | - provide('server', { url: ctx.server!.url }) |
| 26 | + project.provide('server', { url: ctx.server!.url }) |
27 | 27 |
|
28 | 28 | return async function () { |
29 | 29 | await stopServer() |
|
0 commit comments