25 lines
792 B
JavaScript
25 lines
792 B
JavaScript
|
|
import { afterAll, afterEach, beforeAll } from 'vitest'
|
||
|
|
import { setupServer } from 'msw/node'
|
||
|
|
import { http, HttpResponse } from 'msw'
|
||
|
|
|
||
|
|
// Ensure global fetch is available in Node tests
|
||
|
|
// Use Node 18+ global fetch (undici). Do not override so MSW can intercept.
|
||
|
|
|
||
|
|
// Some CI envs inject corporate roots causing TLS issues; disable cert checks in tests only
|
||
|
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
||
|
|
// Ensure MSW intercepts local requests without going through a proxy
|
||
|
|
process.env.HTTP_PROXY = ''
|
||
|
|
process.env.HTTPS_PROXY = ''
|
||
|
|
process.env.ALL_PROXY = ''
|
||
|
|
process.env.NO_PROXY = '*'
|
||
|
|
|
||
|
|
export const server = setupServer()
|
||
|
|
|
||
|
|
beforeAll(() => server.listen({ onUnhandledRequest: 'error' }))
|
||
|
|
|
||
|
|
afterEach(() => server.resetHandlers())
|
||
|
|
|
||
|
|
afterAll(() => server.close())
|
||
|
|
|
||
|
|
export { http, HttpResponse }
|