-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Enterprise Search] Small test helper for expected async errors #88422
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 all commits
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 |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| export const expectedAsyncError = async (promise: Promise<unknown>) => { | ||
| let expectedError: unknown; | ||
|
|
||
| try { | ||
| await promise; | ||
| } catch (e) { | ||
| // Silence expected errors from being reported by tests | ||
|
|
||
| // Pass back expected error to optionally assert on | ||
| expectedError = e; | ||
| } | ||
|
|
||
| return expectedError; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,5 @@ export { mountWithIntl } from './mount_with_i18n.mock'; | |
| export { shallowWithIntl } from './shallow_with_i18n.mock'; | ||
| export { rerender } from './enzyme_rerender.mock'; | ||
| // Note: shallow_useeffect must be imported directly as a file | ||
|
|
||
| export { expectedAsyncError } from './expected_async_error'; | ||
|
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. Just btw, I know I'm getting a little loosey-goosey here with what should go into the
Member
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. I'm not concerned about it. |
||
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.
I like this a lot. I was imagining it'd have to be something more complex, but this is laser focused.
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.
Awesome! We can definitely extend it in the future if we need to is my thought, but maybe we won't have to.