@nuxt/docs-nightly 5.0.0-29754402.327d03a9 → 5.0.0-29755237.d0f4ecbb
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.
|
@@ -734,6 +734,13 @@ Please use the options below for the `setup` method.
|
|
|
734
734
|
- Type: `'vitest' | 'jest' | 'cucumber'`
|
|
735
735
|
- Default: `'vitest'`
|
|
736
736
|
|
|
737
|
+
- `logLevel`: Overrides the consola log level for the server subprocess. (use NUXT_TEST_LOG_LEVEL environment variable to override)
|
|
738
|
+
- Type: `number`
|
|
739
|
+
- Default: `1`
|
|
740
|
+
- `captureServerLogs`: Whether to capture server process output instead of inheriting stdio. When `true` (default), server stdout/stderr is suppressed from the console and accessible via `getServerLogs()`. Set to `false` to restore the old inherit-stdio behaviour (useful when debugging a test locally).
|
|
741
|
+
- Type: `boolean`
|
|
742
|
+
- Default: `true`
|
|
743
|
+
|
|
737
744
|
##### Target `host` end-to-end example
|
|
738
745
|
|
|
739
746
|
A common use-case for end-to-end testing is running the tests against a deployed application running in the same environment typically used for Production.
|
|
@@ -793,6 +800,27 @@ const pageUrl = url('/page')
|
|
|
793
800
|
// 'http://localhost:6840/page'
|
|
794
801
|
```
|
|
795
802
|
|
|
803
|
+
#### `getServerLogs()`
|
|
804
|
+
|
|
805
|
+
Returns the lines captured from the server subprocess's stdout/stderr since the last `startServer()` call (or `clearServerLogs()`). Only populated when `captureServerLogs` is `true` (the default).
|
|
806
|
+
|
|
807
|
+
```ts twoslash
|
|
808
|
+
import { expect, it, vi } from 'vitest'
|
|
809
|
+
import { $fetch, clearServerLogs, getServerLogs } from '@nuxt/test-utils/e2e'
|
|
810
|
+
|
|
811
|
+
it('captures console.log output from a server route', async () => {
|
|
812
|
+
clearServerLogs()
|
|
813
|
+
await $fetch('/api/log-test')
|
|
814
|
+
await vi.waitFor(() => {
|
|
815
|
+
expect(getServerLogs().some(line => line.includes('[test] server-log-marker'))).toBe(true)
|
|
816
|
+
})
|
|
817
|
+
})
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
#### `clearServerLogs()`
|
|
821
|
+
|
|
822
|
+
Clears the captured server log lines. Useful between requests when you want to assert only on the logs produced by a specific operation.
|
|
823
|
+
|
|
796
824
|
### Testing in a Browser
|
|
797
825
|
|
|
798
826
|
We provide built-in support using Playwright within `@nuxt/test-utils`, either programmatically or via the Playwright test runner.
|