-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
A unit test like this fails
import { describe, it, expect } from 'vitest'
import { mountSuspended, registerEndpoint } from '@nuxt/test-utils/runtime'
import App from '~/app.vue'
describe('Testing routes', () => {
registerEndpoint('/api/drupal-ce/prenode', () => ({
content: {
element: 'drupal-markup',
body: '<p>Some <b>example</b> body.</p>'
},
local_tasks: {},
messages: [],
metatags: { meta: [], link: [], jsonld: [] }
}))
registerEndpoint('/api/menu/api/menu_items/main', () => ([
{ title: 'Test page', relative: '/node/1' }
]))
it('renders preview/node with direct backend request, skipping drupal-ce-proxy', async () => {
const component = await mountSuspended(App, {
route: '/prenode'
})
expect(component.html()).toContain('<p>Some <b>example</b> body.</p>')
})
})
when the default [...[.vue is used with some layout like
<template>
<div>
<NuxtLayout name="default">
<main>
<component :is="renderCustomElements(page.content)" />
</main>
</NuxtLayout>
</div>
</template>
<script lang="ts" setup>
const { fetchPage, renderCustomElements } = useDrupalCe()
const page = await fetchPage(useRoute().path, { query: useRoute().query })
</script>
When the NuxtLayout component is removed, it works. Also when the component WITH the NuxtLayout is copied to prenode.vue page component, such that the fallback is not used, then it works also! It seems the mocking of routes of nuxt test utils somehow fails when the fallback component is in use.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels