Modernizes testing infrastructure with dedicated Cloudflare Workers test pool: - Replaces Nuxt Test Utils with @cloudflare/vitest-pool-workers - Adds structured test organization for API endpoints - Introduces comprehensive testing patterns and examples - Implements schema-based test data generation with zod-mock - Enhances test utilities with proper CF Workers environment The new testing setup provides better isolation, more realistic worker runtime environment, and improved test data management through structured schemas and generators.
15 lines
428 B
TypeScript
15 lines
428 B
TypeScript
import { SELF } from 'cloudflare:test'
|
|
|
|
export async function fetchWithAuth(path: string, options?: RequestInit) {
|
|
return SELF.fetch(`http://localhost${path}`, {
|
|
...options,
|
|
headers: {
|
|
...options?.headers,
|
|
Authorization: `Bearer ${import.meta.env.NUXT_SITE_TOKEN}`,
|
|
},
|
|
})
|
|
}
|
|
|
|
export async function fetch(path: string, options?: RequestInit) {
|
|
return SELF.fetch(`http://localhost${path}`, options)
|
|
}
|