test: add e2e plugin ordering assertion

This commit is contained in:
Daniel Roe 2023-08-31 11:01:16 +01:00
parent c5e7cc737d
commit 6468452ccb
4 changed files with 21 additions and 0 deletions

View File

@ -983,6 +983,11 @@ describe('extends support', () => {
const html = await $fetch('/foo')
expect(html).toContain('Plugin | foo: String generated from foo plugin!')
})
it('respects plugin ordering within layers', async () => {
const html = await $fetch('/plugins/ordering')
expect(html).toContain('catchall at plugins')
})
})
describe('server', () => {

View File

@ -0,0 +1,3 @@
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.provide('layerPluginPre', 'layer-plugin')
})

View File

@ -0,0 +1,3 @@
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.provide('layerPluginPost', 'layer-plugin')
})

View File

@ -0,0 +1,10 @@
export default defineNuxtPlugin((nuxtApp) => {
if (useRoute().path === '/plugins/ordering') {
if (!nuxtApp.$layerPluginPre) {
throw createError('layer plugin failed to run before end project plugin')
}
if (nuxtApp.$layerPluginPost) {
throw createError('layer plugin failed to run after end project plugin')
}
}
})