-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test(replay): Test against CDN bundles in Playwright integration tests #6770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e7bc30e
test(replay): Test against CDN bundles in Playwright integration tests
Lms24 58b63e7
add test to continue checking replay browser export
Lms24 c010750
adjust new integration test
Lms24 290f41f
fix _isEnabled
Lms24 927e4ea
remove job condition
Lms24 4239931
remove debug output
Lms24 59dbb57
remove debugger stmt
Lms24 1218c95
try waitForFunction
Lms24 cd0994a
fix linter error
Lms24 589a438
remove waitForFunction
Lms24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
packages/integration-tests/suites/replay/captureReplayViaBrowser/init.js
This file contains hidden or 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,16 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
window.Replay = new Sentry.Replay({ | ||
flushMinDelay: 200, | ||
initialFlushDelay: 200, | ||
}); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
sampleRate: 0, | ||
replaysSessionSampleRate: 1.0, | ||
replaysOnErrorSampleRate: 0.0, | ||
|
||
integrations: [window.Replay], | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/integration-tests/suites/replay/captureReplayViaBrowser/template.html
This file contains hidden or 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,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<button onclick="console.log('Test log')">Click me</button> | ||
</body> | ||
</html> |
68 changes: 68 additions & 0 deletions
68
packages/integration-tests/suites/replay/captureReplayViaBrowser/test.ts
This file contains hidden or 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,68 @@ | ||
import { expect } from '@playwright/test'; | ||
import { SDK_VERSION } from '@sentry/browser'; | ||
import type { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest('captureReplay', async ({ getLocalTestPath, page }) => { | ||
// For this test, we skip all bundle tests, as we're only interested in Replay being correctly | ||
// exported from the `@sentry/browser` npm package. | ||
if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_')) { | ||
sentryTest.skip(); | ||
} | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({ id: 'test-id' }), | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
await page.goto(url); | ||
|
||
await page.click('button'); | ||
await page.waitForTimeout(300); | ||
|
||
const replayEvent = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(replayEvent).toBeDefined(); | ||
expect(replayEvent).toEqual({ | ||
type: 'replay_event', | ||
timestamp: expect.any(Number), | ||
error_ids: [], | ||
trace_ids: [], | ||
urls: [expect.stringContaining('/dist/index.html')], | ||
replay_id: expect.stringMatching(/\w{32}/), | ||
segment_id: 2, | ||
replay_type: 'session', | ||
event_id: expect.stringMatching(/\w{32}/), | ||
environment: 'production', | ||
sdk: { | ||
integrations: [ | ||
'InboundFilters', | ||
'FunctionToString', | ||
'TryCatch', | ||
'Breadcrumbs', | ||
'GlobalHandlers', | ||
'LinkedErrors', | ||
'Dedupe', | ||
'HttpContext', | ||
'Replay', | ||
], | ||
version: SDK_VERSION, | ||
name: 'sentry.javascript.browser', | ||
}, | ||
sdkProcessingMetadata: {}, | ||
request: { | ||
url: expect.stringContaining('/dist/index.html'), | ||
headers: { | ||
'User-Agent': expect.stringContaining(''), | ||
}, | ||
}, | ||
platform: 'javascript', | ||
tags: { sessionSampleRate: 1, errorSampleRate: 0 }, | ||
}); | ||
}); |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.