-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(browser): Add integration tests for new XHR Transport (#4814)
add integration tests to test the new XHR transport introduced in #4803 * the tests are very similar to the new Fetch transport integration tests introduced in #4765. The only difference is that they disable the browsers' Fetch API by setting window.fetch = undefined. This way, the SDK falls back to the XHR transport.
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/integration-tests/suites/new-transports/xhr-captureException/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// deactivate fetch s.t. the SDK falls back to XHR transport | ||
window.fetch = undefined; | ||
|
||
Sentry.captureException(new Error('this is an error')); |
21 changes: 21 additions & 0 deletions
21
packages/integration-tests/suites/new-transports/xhr-captureException/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest('should capture an error with the new fetch transport', async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(eventData.exception?.values).toHaveLength(1); | ||
expect(eventData.exception?.values?.[0]).toMatchObject({ | ||
type: 'Error', | ||
value: 'this is an error', | ||
mechanism: { | ||
type: 'generic', | ||
handled: true, | ||
}, | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
packages/integration-tests/suites/new-transports/xhr-startTransaction/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// deactivate fetch s.t. the SDK falls back to XHR transport | ||
window.fetch = undefined; | ||
|
||
const transaction = Sentry.startTransaction({ name: 'test_transaction_1' }); | ||
transaction.finish(); |
13 changes: 13 additions & 0 deletions
13
packages/integration-tests/suites/new-transports/xhr-startTransaction/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest('should report a transaction with the new XHR transport', async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
const transaction = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(transaction.transaction).toBe('test_transaction_1'); | ||
expect(transaction.spans).toBeDefined(); | ||
}); |