vitest.setup.ts 458 B

1234567891011121314151617
  1. import nock from "nock"
  2. import "./utils/path" // Import to enable String.prototype.toPosix().
  3. // Disable network requests by default for all tests.
  4. nock.disableNetConnect()
  5. export function allowNetConnect(host?: string | RegExp) {
  6. if (host) {
  7. nock.enableNetConnect(host)
  8. } else {
  9. nock.enableNetConnect()
  10. }
  11. }
  12. // Global mocks that many tests expect.
  13. global.structuredClone = global.structuredClone || ((obj: any) => JSON.parse(JSON.stringify(obj)))