-
Notifications
You must be signed in to change notification settings - Fork 882
[EuiErrorBoundary] Add default data-test-subj
#5232
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
Changes from 6 commits
61b9410
f46dd05
86cb9fd
ed6edc3
ae6375c
04104f7
2714c9e
65e9cd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,30 +22,48 @@ const BadComponent = () => { | |
| }; | ||
|
|
||
| describe('EuiErrorBoundary', () => { | ||
| test('is rendered without an error', () => { | ||
| const component = takeMountedSnapshot( | ||
| mount( | ||
| describe('without an error thrown', () => { | ||
| it('UI is not rendered', () => { | ||
| const component = takeMountedSnapshot( | ||
| mount( | ||
| <EuiErrorBoundary {...requiredProps}> | ||
| <GoodComponent /> | ||
| </EuiErrorBoundary> | ||
| ) | ||
| ); | ||
|
|
||
| expect(component).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('with an error thrown', () => { | ||
| it('UI is rendered', () => { | ||
| // Prevent the React boundary error from appearing in the terminal. | ||
| spyOn(console, 'error'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha this blows my mind, I've never actually used I am slightly confused by the comment though, AFAIK (feel free to merge w/o addressing this comment also as I know it's previous code + not a blocker)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Welp, it turns out that the comment is entirely false. Removing Thanks for the question! |
||
|
|
||
| // 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}> | ||
| <GoodComponent /> | ||
| <BadComponent /> | ||
| </EuiErrorBoundary> | ||
| ) | ||
| ); | ||
| ).text(); | ||
|
|
||
| expect(component).toMatchSnapshot(); | ||
| }); | ||
| expect(errorText).toContain(errorMessage); | ||
| }); | ||
|
|
||
| test('is rendered with an error', () => { | ||
| // Prevent the React boundary error from appearing in the terminal. | ||
| spyOn(console, 'error'); // eslint-disable-line no-undef | ||
| it('data-test-subj is rendered', () => { | ||
|
thompsongl marked this conversation as resolved.
Outdated
|
||
| // Prevent the React boundary error from appearing in the terminal. | ||
| spyOn(console, 'error'); | ||
|
|
||
| // 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(); | ||
| const errorHtml = mount( | ||
| <EuiErrorBoundary {...requiredProps}> | ||
| <BadComponent /> | ||
| </EuiErrorBoundary> | ||
| ).html(); | ||
|
|
||
| expect(errorText).toContain(errorMessage); | ||
| expect(errorHtml).toContain('euiErrorBoundary'); | ||
| expect(errorHtml).toContain('test subject string'); | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.