Nuxt/test/setup-runtime.ts
renovate[bot] 17ff2d5c98
chore(deps): update all non-major dependencies (3.x) (#28302)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
2024-08-06 15:16:20 +01:00

31 lines
810 B
TypeScript

import { vi } from 'vitest'
import { defineEventHandler } from 'h3'
import { registerEndpoint } from '@nuxt/test-utils/runtime'
vi.mock('#app/compat/idle-callback', () => ({
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
requestIdleCallback: (cb: Function) => cb(),
cancelIdleCallback: () => {},
}))
const timestamp = Date.now()
registerEndpoint('/_nuxt/builds/latest.json', defineEventHandler(() => ({
id: 'override',
timestamp,
})))
registerEndpoint('/_nuxt/builds/meta/override.json', defineEventHandler(() => ({
id: 'override',
timestamp,
matcher: {
static: {
'/': null,
'/pre': null,
'/pre/test': { redirect: true },
},
wildcard: { '/pre': { prerender: true } },
dynamic: {},
},
prerendered: ['/specific-prerendered'],
})))