-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
Ignore style.loadURL
abort error when style is removed
#4425
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4425 +/- ##
==========================================
- Coverage 87.94% 87.40% -0.54%
==========================================
Files 246 246
Lines 33396 33397 +1
Branches 2173 2208 +35
==========================================
- Hits 29371 29192 -179
- Misses 3033 3191 +158
- Partials 992 1014 +22 ☔ View full report in Codecov by Sentry. |
Thanks for taking the time to open this PR! |
Thank you @HarelM for the review. Should I open a new PR to add a test of the error firing in case it isn't an abort error, to ensure coverage of the |
Here would be better. THANKS! |
Besides the test nit-picking this looks good. |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
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!
src/style/style.test.ts
Outdated
|
||
style.on('error', spy); | ||
style.loadURL('style.json'); | ||
const promise = new Promise((_, reject) => { |
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 other places are using a simpler method:
expect((server.lastRequest as any).aborted).toBe(true);
I think it can be used here as well.
I'll open a PR to update the types so we can remove these "as any".
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.
expect((server.lastRequest as any).aborted).toBe(true);
is used to test if the request has been aborted, which the test above does ('cancels pending requests if removed'
). In our case, we want to test that, when the request is aborted, no error are fired.
Removing these "as any" would be nice, thanks.
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.
Using expect((server.lastRequest as any).aborted).toBe(true);
would remove the need to use this promise, and wait for it rejection. I find it more elegant. You might still need a sleep(0)
though.
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've updated the nise types, now you can use it without the "as any":
#4446
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've updated the nise types, now you can use it without the "as any"
Thanks !
Using expect((server.lastRequest as any).aborted).toBe(true); would remove the need to use this promise, and wait for it rejection. I find it more elegant. You might still need a sleep(0) though.
We would still need a sleep(0)
since the rejection is asynchronous. Without it, the test succeed even if the Style fires the abort error. The promise is just a way to wait for the rejection we want to test rather than just wait for a bit with the sleep(0)
, but I agree it's not very elegant and it might be too bound to implementation. Should I revert to sleep(0)
?
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.
Yes please.
Fixes #4400
Ignore the abort error raised by
style.loadURL
when the style is removed.Launch Checklist
CHANGELOG.md
under the## main
section.