-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[core] Batch small changes #23422
[core] Batch small changes #23422
Conversation
oliviertassinari
commented
Nov 7, 2020
•
edited
Loading
edited
- [docs] I can't find any lead that suggests that Safari 12.2 exists 09dfbab.
- [test] Catch error between tests 323b350: The issue was found in [test] Karma should fail if errors are thrown mui-x#543. I also create a new setupKarma.js file so the X repo can import it directly (avoid duplication).
- [docs] Update README with Matt review 5aff922: leverage [docs] Add more information to readme mui-x#539.
The issue was found in mui/mui-x#543. I also create a new setupKarma.js file so the X repo can import it directly.
}); | ||
}); | ||
|
||
// Ensure that uncaught exceptions between tests result in the tests failing. |
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.
How can I repro this? It's not clear whether this error should be caught here or if there's some other problematic test behavior that should actually be removed.
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.
mui/mui-x#543 was meant to be the reproduction (failing CI). It fails on this test https://github.com/mui-org/material-ui-x/blob/453e2f14f6981cda278faf0ce1edb8a7e543078d/packages/grid/x-grid/src/XGrid.test.tsx#L80-L89 (and the others). If you want to reproduce with fewer changes you can do:
- Check out a commit on
master
before [test] Karma should fail if errors are thrown mui-x#543 - Change the logic of the component to throw an async error:
diff --git a/packages/grid/_modules_/grid/hooks/utils/useResizeContainer.ts b/packages/grid/_modules_/grid/hooks/utils/useResizeContainer.ts
index e9750e8a..4297f4c1 100644
--- a/packages/grid/_modules_/grid/hooks/utils/useResizeContainer.ts
+++ b/packages/grid/_modules_/grid/hooks/utils/useResizeContainer.ts
@@ -8,6 +8,7 @@ export function useResizeContainer(apiRef): (size: ElementSize) => void {
const onResize = React.useCallback(
(size: ElementSize) => {
+ throw new Error('ooop')
if (size.height === 0) {
gridLogger.warn(
[
diff --git a/test/karma.conf.js b/test/karma.conf.js
- Run the tests with
yarn test:karma
- the first test passes, all the other are skipped 💥
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.
So just to be clear:
- This does not cover all cases.
- What we should catch is components that don't clean up.
The problem isn't that an error was thrown between tests but that the component/test leaks.
I'm not that happy with the new listener since it might trick people into thinking errors between tests are caught and you're safe. Let's see if that produces problematic component code/tests. In the end we shouldn't actually add code we don't need.
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.
What do you recommend we do here? No strong preferences. If we can get test/utils/setupKarma.js
to be shared with X, but with the need to keep the patch for karma-runner/karma-mocha#227 on X only, it will already be a good step forward in sharing code.
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.
Nah, all good to merge. Just want to caution that we don't get a false sense of security.