diff --git a/packages/nuxt/__tests__/nuxt.spec.ts b/packages/nuxt/__tests__/nuxt.spec.ts index 30a74f3a77..563e94b432 100644 --- a/packages/nuxt/__tests__/nuxt.spec.ts +++ b/packages/nuxt/__tests__/nuxt.spec.ts @@ -34,8 +34,9 @@ describe('works with nuxt', async () => { expect(html).toContain('Count: 101') }) - it.todo('drop state that is marked with skipHydrate', async () => { + it('drops state that is marked with skipHydrate', async () => { const html = await $fetch('/skip-hydrate') - // TODO: + expect(html).not.toContain('I should not be serialized or hydrated') + expect(html).toContain('skipHydrate-wrapped state is correct') }) }) diff --git a/packages/nuxt/playground/pages/skip-hydrate.vue b/packages/nuxt/playground/pages/skip-hydrate.vue index 2ad72bb296..5e3ffa00d9 100644 --- a/packages/nuxt/playground/pages/skip-hydrate.vue +++ b/packages/nuxt/playground/pages/skip-hydrate.vue @@ -1,8 +1,13 @@ diff --git a/packages/nuxt/playground/tsconfig.json b/packages/nuxt/playground/tsconfig.json new file mode 100644 index 0000000000..4b34df1571 --- /dev/null +++ b/packages/nuxt/playground/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "./.nuxt/tsconfig.json" +} diff --git a/packages/nuxt/src/runtime/payload-plugin.ts b/packages/nuxt/src/runtime/payload-plugin.ts index 2479225613..8563543257 100644 --- a/packages/nuxt/src/runtime/payload-plugin.ts +++ b/packages/nuxt/src/runtime/payload-plugin.ts @@ -11,9 +11,10 @@ import { shouldHydrate } from 'pinia' const payloadPlugin = definePayloadPlugin(() => { definePayloadReducer( 'skipHydrate', - (data: unknown) => !shouldHydrate(data) && undefined + // We need to return something truthy to be treated as a match + (data: unknown) => !shouldHydrate(data) && 1 ) - definePayloadReviver('skipHydrate', (data: undefined) => data) + definePayloadReviver('skipHydrate', (_data: 1) => undefined) }) export default payloadPlugin