-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Clear the console in browser on each HMR #1073
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1073 +/- ##
=========================================
+ Coverage 88.64% 89.94% +1.3%
=========================================
Files 71 71
Lines 3504 3660 +156
=========================================
+ Hits 3106 3292 +186
+ Misses 398 368 -30
Continue to review full report at Codecov.
|
src/builtins/hmr-runtime.js
Outdated
@@ -32,6 +32,9 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') { | |||
hmrAccept(global.require, asset.id); | |||
} | |||
}); | |||
// Clear the console after HMR | |||
// Check if console.clear function is supported, absence of this caused tests to fail | |||
console.clear && console.clear(); |
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.
Probably better to use a mock function for the tests like I explained in #1074
This way you could also make the tests test if it actually happens
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.
Sure @DeMoorJasper I will use a mock function to fix it.
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.
Hi @DeMoorJasper I have mocked the function console.clear() in test
@DeMoorJasper I have done the changes you requested please do review |
@DeMoorJasper Is there anything else I need to do to get my pull request merged |
@ameerthehacker No it should be fine, but as in the discussion it might not get merged as some developers might not want parcel clearing their console. |
@DeMoorJasper that is great |
What was missing ?
Whenever there was an HRM the console in the browser had old logging data #1064
What I have added ?
I have modified the hmr-runtime.js file to include a console.clear() statement to clear the console whenever there is an HRM
Little workaround I used
If I used console.clear() some of the test were breaking complaining that Error: TypeError console.clear function is undefined I think that the testing environment does not support console.clear() function so I replaced the statement in such a way that it will be called only if it is supported.