Skip to content

Commit

Permalink
Fix EuiErrorBoundary tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Feb 21, 2018
1 parent e8c94c1 commit 6fcb421
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,70 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiErrorBoundary is rendered with an error 1`] = `
<div
aria-label="aria-label"
class="testClass1 testClass2"
data-test-subj="test subject string"
>
<div
class="euiErrorBoundary__text"
>
<div
class="euiText euiText--extraSmall"
>
<h1>
Error
</h1>
<pre
class="euiErrorBoundary__stack"
>
<p>
Error: I'm here to kick butt and chew bubblegum.
And I'm all out of gum.
at BadComponent (/Users/cjcenizal/Documents/GitHub/Elastic/eui/src/components/error_boundary/error_boundary.test.js:15:9)
at mountIndeterminateComponent (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:8032:15)
at beginWork (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:8221:16)
at performUnitOfWork (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:10224:16)
at workLoop (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:10288:26)
at HTMLUnknownElement.callCallback (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:542:14)
at invokeEventListeners (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
at HTMLUnknownElementImpl._dispatch (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
at HTMLUnknownElementImpl.dispatchEvent (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
at HTMLUnknownElementImpl.dispatchEvent (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:30:27)
at HTMLUnknownElement.dispatchEvent (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
at Object.invokeGuardedCallbackDev (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:581:16)
at invokeGuardedCallback (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:438:27)
at renderRoot (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:10366:7)
at performWorkOnRoot (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:11014:24)
at performWork (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:10967:7)
at requestWork (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:10878:7)
at scheduleWorkImpl (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:10732:11)
at scheduleWork (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:10689:12)
at scheduleTopLevelUpdate (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:11193:5)
at Object.updateContainer (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:11231:7)
at /Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:15226:19
at Object.unbatchedUpdates (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:11102:12)
at renderSubtreeIntoContainer (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:15225:17)
at Object.render (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/react-dom/cjs/react-dom.development.js:15290:12)
at Object.render (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:218:50)
at new ReactWrapper (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/enzyme/build/ReactWrapper.js:98:16)
at mount (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/enzyme/build/mount.js:19:10)
at Object.&lt;anonymous&gt; (/Users/cjcenizal/Documents/GitHub/Elastic/eui/src/components/error_boundary/error_boundary.test.js:34:39)
at Object.asyncFn (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/jest-jasmine2/build/jasmine_async.js:129:432)
at resolve (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/jest-jasmine2/build/queue_runner.js:51:12)
at Promise (&lt;anonymous&gt;)
at mapper (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/jest-jasmine2/build/queue_runner.js:40:274)
at promise.then (/Users/cjcenizal/Documents/GitHub/Elastic/eui/node_modules/jest-jasmine2/build/queue_runner.js:83:39)
at &lt;anonymous&gt;
at process._tickCallback (internal/process/next_tick.js:169:7)
</p>
</pre>
</div>
</div>
</div>
`;

exports[`EuiErrorBoundary is rendered without an error 1`] = `
<div>
No error
Expand Down
20 changes: 11 additions & 9 deletions src/components/error_boundary/error_boundary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,35 @@ const GoodComponent = () => (
<div>No error</div>
);

const errorMessage = 'I\'m here to kick butt and chew bubblegum.\n\n\And I\'m all out of gum.';

const BadComponent = () => {
throw new Error('I\'m here to kick butt and chew bubblegum.\n\n\And I\'m all out of gum.');
throw new Error(errorMessage);
};

describe('EuiErrorBoundary', () => {
test('is rendered without an error', () => {
const component = mount(
const component = takeMountedSnapshot(mount(
<EuiErrorBoundary {...requiredProps}>
<GoodComponent />
</EuiErrorBoundary>
);
));

expect(takeMountedSnapshot(component))
.toMatchSnapshot();
expect(component).toMatchSnapshot();
});

test('is rendered with an error', () => {
// Prevent the React boundary error from appearing in the terminal.
spyOn(console, 'error'); // eslint-disable-line no-undef

const component = mount(
// Because the error contains the stack trace, it's non-deterministic. So we'll just check that
// it contains our error message.
const errorText = mount(
<EuiErrorBoundary {...requiredProps}>
<BadComponent />
</EuiErrorBoundary>
);
).text();

expect(takeMountedSnapshot(component))
.toMatchSnapshot();
expect(errorText).toContain(errorMessage);
});
});

0 comments on commit 6fcb421

Please sign in to comment.