Skip to content

Commit cf1869a

Browse files
committed
prevent error boundry warning in test from react 16
1 parent 550833a commit cf1869a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

__tests__/Parallax.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ describe('Expect the <Parallax> component', () => {
1414

1515
it('to throw if the ParallaxController is not available', () => {
1616
const node = document.createElement('div');
17+
// NOTE: hide error and react warning
18+
// see issue: https://github.com/facebook/jest/issues/4597
19+
const preventError = e => e.preventDefault();
20+
window.addEventListener('error', preventError, true);
21+
Error.prototype.suppressReactErrorLogging = true;
1722

1823
const render = () => {
1924
ReactDOM.render(
@@ -27,6 +32,9 @@ describe('Expect the <Parallax> component', () => {
2732
expect(render).toThrow(
2833
"Must wrap your application's <Parallax /> components in a <ParallaxProvider />."
2934
);
35+
36+
window.removeEventListener('error', preventError, true);
37+
Error.prototype.suppressReactErrorLogging = false;
3038
});
3139

3240
it('to warn if the ParallaxController is found but not provided by <ParallaxProvider>', () => {

0 commit comments

Comments
 (0)