Skip to content

Commit fe1c8d3

Browse files
committed
refactor: move to e2e utils
1 parent 4dd3e8e commit fe1c8d3

File tree

8 files changed

+13
-15
lines changed

8 files changed

+13
-15
lines changed

build.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export default defineBuildConfig({
99
'src/experimental',
1010
'src/config',
1111
'src/module.ts',
12-
isStub ? { input: 'src/module-utils/', outDir: 'dist/module-utils', format: 'esm' } : 'src/module-utils/index.mjs',
1312
'src/vitest-environment',
1413
isStub ? { input: 'src/runtime-utils/', outDir: 'dist/runtime-utils', format: 'esm' } : 'src/runtime-utils/index.mjs',
1514
{ input: 'src/runtime/', outDir: 'dist/runtime', format: 'esm' }
@@ -18,6 +17,5 @@ export default defineBuildConfig({
1817
"#app/entry",
1918
"#build/root-component.mjs",
2019
"#imports",
21-
],
22-
failOnWarn: false,
20+
]
2321
})

examples/module/test/basic.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { fileURLToPath } from 'node:url'
22
import { describe, expect, it } from 'vitest'
3-
import { $fetch, setup } from '@nuxt/test-utils/e2e'
4-
import { setRuntimeConfig } from '@nuxt/test-utils/module-utils'
3+
import { $fetch, setRuntimeConfig, setup } from '@nuxt/test-utils/e2e'
54

65
describe('ssr', async () => {
76
await setup({
@@ -17,7 +16,7 @@ describe('ssr', async () => {
1716

1817
it('changes runtime config and restarts', async () => {
1918
const restoreConfig = await setRuntimeConfig({ public: { myValue: 'overwritten by test!' } })
20-
19+
2120
const html = await $fetch('/')
2221
expect(html).toContain('<div>basic <span>overwritten by test!</span></div>')
2322

module-utils.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"./e2e": "./dist/e2e.mjs",
1616
"./experimental": "./dist/experimental.mjs",
1717
"./module": "./dist/module.mjs",
18-
"./module-utils": "./dist/module-utils/index.mjs",
1918
"./runtime": "./dist/runtime-utils/index.mjs",
2019
"./vitest-environment": "./dist/vitest-environment.mjs"
2120
},
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { snakeCase } from "scule"
2-
import { startServer } from "../e2e";
1+
import { snakeCase } from 'scule'
2+
import { startServer } from './server'
33

44
const NUXT_ENV_PREFIX = 'NUXT_'
55

src/core/server.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import * as _kit from '@nuxt/kit'
66
import { resolve } from 'pathe'
77
import { useTestContext } from './context'
88

9-
109
// @ts-expect-error type cast
1110
// eslint-disable-next-line
1211
const kit: typeof _kit = _kit.default || _kit
1312

14-
export async function startServer (env: Record<string, unknown> = {}) {
13+
export interface StartServerOptions {
14+
env?: Record<string, unknown>
15+
}
16+
17+
export async function startServer (options: StartServerOptions = {}) {
1518
const ctx = useTestContext()
1619
await stopServer()
1720
const host = '127.0.0.1'
@@ -28,7 +31,7 @@ export async function startServer (env: Record<string, unknown> = {}) {
2831
PORT: String(port),
2932
HOST: host,
3033
NODE_ENV: 'development',
31-
...env
34+
...options.env
3235
}
3336
})
3437
await waitForPort(port, { retries: 32, host }).catch(() => {})
@@ -56,7 +59,7 @@ export async function startServer (env: Record<string, unknown> = {}) {
5659
PORT: String(port),
5760
HOST: host,
5861
NODE_ENV: 'test',
59-
...env
62+
...options.env
6063
}
6164
})
6265
await waitForPort(port, { retries: 20, host })

src/e2e.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export * from './core/nuxt'
55
export * from './core/server'
66
export * from './core/setup/index'
77
export * from './core/run'
8+
export * from './core/runtime-config'
89
export * from './core/types'

src/module-utils/index.mjs

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)