Skip to content

Commit

Permalink
Skip IE11 since fetch is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Boutaib committed Jun 27, 2024
1 parent d3f3bd6 commit 27a4696
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions packages/rum-core/src/boot/preStartRum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
resetExperimentalFeatures,
resetFetchObservable,
resetXhrObservable,
isIE,
} from '@datadog/browser-core'
import type { Clock } from '@datadog/browser-core/test'
import {
Expand Down Expand Up @@ -700,29 +701,37 @@ describe('preStartRum', () => {
strategy = createPreStartStrategy({}, getCommonContextSpy, trackingConsentState, doStartRumSpy)
})

it('should instrument fetch and XHR even if tracking consent is not granted', () => {
const originalFetch = window.fetch
/* eslint-disable @typescript-eslint/unbound-method */
const originalXHROpen = XMLHttpRequest.prototype.open
const originalXHRSend = XMLHttpRequest.prototype.send
const originalXHRAbort = XMLHttpRequest.prototype.abort
/* eslint-disable @typescript-eslint/unbound-method */
describe('basic methods instrumentation', () => {
beforeEach(() => {
if (isIE()) {
pending('No support for IE')
}
})

strategy.init(
{
...DEFAULT_INIT_CONFIGURATION,
trackingConsent: TrackingConsent.NOT_GRANTED,
},
PUBLIC_API
)
it('should instrument fetch and XHR even if tracking consent is not granted', () => {
const originalFetch = window.fetch
/* eslint-disable @typescript-eslint/unbound-method */
const originalXHROpen = XMLHttpRequest.prototype.open
const originalXHRSend = XMLHttpRequest.prototype.send
const originalXHRAbort = XMLHttpRequest.prototype.abort
/* eslint-disable @typescript-eslint/unbound-method */

expect(window.fetch).not.toBe(originalFetch)
strategy.init(
{
...DEFAULT_INIT_CONFIGURATION,
trackingConsent: TrackingConsent.NOT_GRANTED,
},
PUBLIC_API
)

/* eslint-disable @typescript-eslint/unbound-method */
expect(XMLHttpRequest.prototype.open).not.toBe(originalXHROpen)
expect(XMLHttpRequest.prototype.send).not.toBe(originalXHRSend)
expect(XMLHttpRequest.prototype.abort).not.toBe(originalXHRAbort)
/* eslint-disable @typescript-eslint/unbound-method */
expect(window.fetch).not.toBe(originalFetch)

/* eslint-disable @typescript-eslint/unbound-method */
expect(XMLHttpRequest.prototype.open).not.toBe(originalXHROpen)
expect(XMLHttpRequest.prototype.send).not.toBe(originalXHRSend)
expect(XMLHttpRequest.prototype.abort).not.toBe(originalXHRAbort)
/* eslint-disable @typescript-eslint/unbound-method */
})
})

it('does not start rum if tracking consent is not granted at init', () => {
Expand Down

0 comments on commit 27a4696

Please sign in to comment.