Skip to content

Conversation

grncdr
Copy link
Contributor

@grncdr grncdr commented Sep 10, 2019

This has comes up every so often in issues and Spectrum, so I've tried to summarize the cause & resolutions available.

grncdr and others added 3 commits September 10, 2019 09:47
This has comes up every so often in issues and Spectrum, so I've tried to summarize the cause & resolutions available.
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Thanks for this!


Learn more about how Jest mocks work from my blog post:
["But really, what is a JavaScript mock?"](https://blog.kentcdodds.com/but-really-what-is-a-javascript-mock-10d060966f7d)
["But really, what is a JavaScript mock?"](https://kentcdodds.com/blog/but-really-what-is-a-javascript-mock)
Copy link
Member

Choose a reason for hiding this comment

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

Just noticed this and couldn't help myself 🙃

This warning is usually caused by an async operation causing an update after
the test has already finished. There are 2 approaches to resolve it:

1. Wait for the result of the operation in your test by using one of
Copy link
Member

Choose a reason for hiding this comment

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

Wanted to make sure people knew that any of the async utilities will solve this. And in many cases using a find* query makes a lot of sense, so I changed the example to that.

@kentcdodds kentcdodds merged commit 535b757 into testing-library:master Sep 10, 2019
@kentcdodds
Copy link
Member

@all-contributors please add @grncdr for docs

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @grncdr! 🎉

@grncdr grncdr deleted the patch-1 branch September 11, 2019 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants