File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 11import { fileURLToPath } from 'node:url'
22import { describe , expect , it } from 'vitest'
33import { $fetch , setup } from '@nuxt/test-utils/e2e'
4+ import { setRuntimeConfig } from '@nuxt/test-utils/module-utils'
45
56describe ( 'ssr' , async ( ) => {
67 await setup ( {
@@ -10,6 +11,18 @@ describe('ssr', async () => {
1011 it ( 'renders the index page' , async ( ) => {
1112 // Get response to a server-rendered page with `$fetch`.
1213 const html = await $fetch ( '/' )
13- expect ( html ) . toContain ( '<div>basic</div>' )
14+ expect ( html ) . toContain ( '<div>basic <span>original value</span></div>' )
15+ } )
16+
17+
18+ it ( 'changes runtime config and restarts' , async ( ) => {
19+ const restoreConfig = await setRuntimeConfig ( { public : { myValue : 'overwritten by test!' } } )
20+
21+ const html = await $fetch ( '/' )
22+ expect ( html ) . toContain ( '<div>basic <span>overwritten by test!</span></div>' )
23+
24+ await restoreConfig ( )
25+ const htmlRestored = await $fetch ( '/' )
26+ expect ( htmlRestored ) . toContain ( '<div>basic <span>original value</span></div>' )
1427 } )
1528} )
Original file line number Diff line number Diff line change 11<template >
2- <div >basic</div >
2+ <div >basic < span >{{ config.public.myValue }}</ span > </div >
33</template >
44
55<script setup>
6+ const config = useRuntimeConfig ();
67 </script >
Original file line number Diff line number Diff line change 11import MyModule from '../../../src/module'
22
33export default defineNuxtConfig ( {
4+ runtimeConfig : {
5+ public : {
6+ myValue : 'original value' ,
7+ } ,
8+ } ,
49 modules : [
510 MyModule
611 ]
You can’t perform that action at this time.
0 commit comments