-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Browser SDK Integration Tests #3989
Conversation
size-limit report
|
3abadea
to
50e1b56
Compare
3aaaf76
to
c28ceac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, yeah I think the test setup is good.
expect(eventData.message).toBe('test'); | ||
expect(eventData.breadcrumbs.length).toBe(1); | ||
expect(eventData.breadcrumbs[0].category).toBe('xhr'); | ||
expect(eventData.breadcrumbs[0].type).toBe('http'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it'll be effective to us to pseudo snapshot test the event instead of these deep assertions.
So we can skip attributes that we know will change, but compare the rest of the event to a json file.
We do something similar in electron:
An event JSON: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/javascript/main-error/event.json
and how it's normalized: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/recipe/normalize.ts#L49
We can also try this out after this gets merged in, no rush
195f6e2
to
0a47492
Compare
1dcd4e0
to
0e2a049
Compare
@AbhiPrasad, added a manual about the basic usage and common issues. Will need to be extended further after merging the rest of the tests. The PR is ready to be reviewed again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @onurtemizkan! I did a pass at this, trying to help us flush this out.
Most comments are small things we can improve or honest questions to help me understand better and also document decisions for our future selves working with and maintaining the code.
My biggest concern for now is around the ability to run individual tests in a single browser in a local development environment.
And then, next, we can strategize how the migration from old tests to new is going to take place as I can see we all need to be careful to not introduce unintended changes (I've seen some unexpected differences and commented).
packages/browser/test/e2e/suites/breadcrumbs/xhr_without_handler/test.ts
Outdated
Show resolved
Hide resolved
packages/browser/test/e2e/suites/breadcrumbs/xhr_without_handler/test.ts
Outdated
Show resolved
Hide resolved
packages/browser/test/e2e/suites/breadcrumbs/xhr_without_handler/test.ts
Outdated
Show resolved
Hide resolved
"main": "index.js", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=12" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any advantage in saying >=12
instead of >=16
here? We're configuring the GHA workflow to run on Node 16.x, I don't think we need to declare compatibility with anything else. Thoughts?
@rhcarvalho, the summary of the latest updates is below;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last set of things, and then I think we are good to go!
@@ -0,0 +1,31 @@ | |||
{ | |||
"name": "sentry-browser-integration-tests", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call the folder name browser-integration-tests
then?
"html-webpack-plugin": "^5.5.0", | ||
"playwright": "^1.17.1", | ||
"ts-loader": "^9.2.6", | ||
"typescript": "^4.5.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to stick with 3.7.5
to match with the rest of the codebase. Can we remove this?
"typescript": "^4.5.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AbhiPrasad, @playwright/test
uses export type
syntax for its types (and we're importing them). It's not a problem while running tests, but addressing #3989 (comment), to run a type check without compiling before tests, we need a newer version of TS. We also no longer need ts-loader
as init
and subject
scripts are not TS. So the only use of TS here will be static type checking. So is that fine to keep this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For ref: c3d35b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked with @AbhiPrasad, and we agreed we can address this later in a follow up.
Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
// This has a big impact on test build speed. | ||
transpileOnly: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this option documented in https://webpack.js.org/guides/build-performance/#typescript-loader
I could not find where we're actually doing the type-checking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a non-compiled type checking script and removed ts-loader
from webpack which we don't need anymore. -> c3d35b6
But we need a higher version of TS for this. -> #3989 (comment)
For our later reference, the last Playwright tests took 1m6s, of which 59s was downloading browsers/system dependencies (and as per #3989 (comment) I think we can get rid of this step and save time). |
Co-authored-by: Rodolfo Carvalho <rodolfo.carvalho@sentry.io>
…tsentry/sentry-javascript into onur/playwright-browser-tests
… into onur/playwright-browser-tests
Ok, we got now the test failure in 3 browsers as expected: https://github.com/getsentry/sentry-javascript/runs/4520662297?check_suite_focus=true However, tests are not running in Webkit due to missing system level dependencies -- we need to apply a fix similar to https://github.com/getsentry/sentry-javascript/pull/4232/files#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721R304 |
All feedback has been addressed or will be addressed in a follow up
Now we have all browsers testing and failing as expected https://github.com/getsentry/sentry-javascript/runs/4521042164?check_suite_focus=true. Tests flipped to green in 84f529b and we should get it merged as soon as the new run turn green. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @onurtemizkan! Looking forward to what we build on top of this ❤️
Thanks everyone for the reviews! ❤️ 🚀 |
Initial structure of new integration tests for Sentry's Browser SDK. New integration tests internally use Playwright and run on recent versions of Chromium, Webkit and Firefox linked with the Playwright release. This new test structure aims to create a modern and intuitive environment to test @sentry/browser and potentially other browser-side SDKs like @sentry/react and @sentry/vue. Co-authored-by: Rodolfo Carvalho <rodolfo.carvalho@sentry.io> Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
Rel: #3841
This PR includes the initial structure of new integration tests for Sentry's Browser SDK.
New integration tests internally use Playwright and run on recent versions of Chromium, Webkit and Firefox linked with the Playwright release.
This new test structure aims to create a modern and intuitive environment to test
@sentry/browser
and potentially other browser-side SDKs like@sentry/react
and@sentry/vue
.