Skip to content
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

Improve error message when Promise is passed into jest-dom matcher #139

Merged
merged 4 commits into from
Jul 7, 2021

Conversation

calebeby
Copy link
Member

@calebeby calebeby commented Jul 7, 2021

If you do this:

await expect(screen.getByText(/asdf/))

That code is wrong because the getByText query is not awaited.

Previously, the error message in that case was along the lines of elementHandle.asElement is not a function. Now the error message is:

Screen Shot 2021-07-07 at 8 11 16 AM

Copy link
Member

@Paul-Hebert Paul-Hebert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and tests look good! Left one non-blocking nit inline.

This is a great DX improvement! I've been bitten by forgetting await in Stencil E2E tests and the error there is much less helpful 😅

src/extend-expect.ts Outdated Show resolved Hide resolved
tests/extend-expect.test.ts Show resolved Hide resolved
@calebeby calebeby merged commit 1d5f16c into main Jul 7, 2021
@calebeby calebeby deleted the improve-jest-dom-promise-error branch July 7, 2021 22:38
@github-actions github-actions bot mentioned this pull request Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants