Closed DavidRieman closed 5 months ago
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit f7ccda28fcd61aac636b28df3ea5b33cbd449bb5:
Sandbox | Source |
---|---|
react-testing-library-examples | Configuration |
Basically we reduce the number of caught exceptions?
Indeed, unexceptional exceptions are a thorny problem in the JS ecosystem due to continued lack of sufficient IDE support for the kind of "just my code" debugger halting features that have existed for decades in other ecosystems. (This one in particular stings me at least once a year so I finally resolved to fix it at the source.) What are our next steps?
Needs to be reverted in https://github.com/testing-library/dom-testing-library/pull/1325 since it caused https://github.com/testing-library/dom-testing-library/issues/1322. Relanding in https://github.com/testing-library/dom-testing-library/issues/1323
What: Added tests for
pretty-dom
to guard against potential behavioral regressions. Then optimizedshouldHighlight
inpretty-dom
to avoid unexceptional exceptions.Why: When developers are using the debugging features to halt the debugger upon "caught exceptions" or "first-chance exceptions" as it may be called in some IDEs, unrelated test failures were disruptively stealing the developer's attention and contributing to premature test timeouts. These disruptions are generally unnecessary since the situation leading up to it can be easily avoided with refactoring.
The exception at hand is that
JSON.parse
throws when passed undefined and/or empty string values. It can be easily avoided because we know that it will throw, and we know the intent is to default the colorization selection.How: Streamlined the logic in
shouldHighlight
to preserve the final result while including extra safety checks to avoid passing undefined/empty to JSON.parse.Checklist: