Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ function setupWrappedFetch(downstreamFetch: typeof fetch): { wrappedFetch: typeo
}

describe('fetch wrapper', () => {
// Use fake timers to prevent getRequestPerformanceEntry retry timeouts
// from keeping the Jest worker alive after tests complete.
beforeEach(() => jest.useFakeTimers())
afterEach(() => jest.useRealTimers())

describe('does not throw for valid inputs', () => {
let wrappedFetch: typeof fetch
let cleanup: () => void
Expand Down
6 changes: 6 additions & 0 deletions packages/browser/src/__tests__/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ beforeEach(() => {
console.warn = (...args) => {
throw new Error(`Unexpected console.warn: ${args}`)
}

// Prevent jsdom XHR requests from creating open handles (TLSWRAP/Timeout)
// that keep Jest from exiting. No unit tests need real HTTP responses.
if (typeof XMLHttpRequest !== 'undefined') {
jest.spyOn(XMLHttpRequest.prototype, 'send').mockImplementation(() => {})
}
})
Loading