NuxtN
Nuxt14mo ago
ægteemil

How to test middleware

Is there a way outside of testing for location headers to test middleware? I'd like to just test this small piece of middleware directly
export default defineNuxtRouteMiddleware(async (to) => {
    if (unauthorizedPaths.includes(to.path))
        return;

    const merchantStore = useMerchantStore();
    if (merchantStore.currentMerchant)
        return;

    return navigateTo('/welcome');
});
Was this page helpful?