]* data-prehydrate-id=":(?
[^:]+)::(?[^:]+):"> onPrehydrate testing <\/div>/)?.groups || {}
+ expect(id1).toBeTruthy()
+ const matches = [
+ html.match(/`)),
+ html.match(new RegExp(``)),
+ ]
+
+ // This tests we inject all scripts correctly, and only have one occurrence of multiple calls of a composable
+ expect(matches.every(s => s?.length === 1)).toBeTruthy()
+
+ // Check for hydration/syntax errors on client side
+ await expectNoClientErrors('/composables/on-prehydrate')
+ })
+
it('respects preview mode with a token', async () => {
const token = 'hehe'
const page = await createPage(`/preview?preview=true&token=${token}`)
diff --git a/test/fixtures/basic/pages/composables/on-prehydrate.vue b/test/fixtures/basic/pages/composables/on-prehydrate.vue
new file mode 100644
index 0000000000..ceaf066aa7
--- /dev/null
+++ b/test/fixtures/basic/pages/composables/on-prehydrate.vue
@@ -0,0 +1,22 @@
+
+
+
+
+ onPrehydrate testing
+
+
diff --git a/test/nuxt/composables.test.ts b/test/nuxt/composables.test.ts
index ecd504236a..5c20e9a038 100644
--- a/test/nuxt/composables.test.ts
+++ b/test/nuxt/composables.test.ts
@@ -100,6 +100,7 @@ describe('composables', () => {
'preloadRouteComponents',
'reloadNuxtApp',
'refreshCookie',
+ 'onPrehydrate',
'useFetch',
'useHead',
'useLazyFetch',