ovidiuch / react-testing-examples

Searchable library of React testing examples
https://react-testing-examples.netlify.app
MIT License
387 stars 29 forks source link

Async but does it need to be? #30

Open harkinj opened 5 years ago

harkinj commented 5 years ago

Hi, Thanks for this great site. This 1st simple test uses
await waitForElement(() => getByText(/hello Satoshi/i))

does it need to use waitForElement? Would getByText alone work? Thanks for the info. John

ovidiuch commented 5 years ago

Good question @harkinj,

Not sure what the right answer is. On one hand waitForElement is more future proof if you use this test as a template for more complicated tests where the text is rendered asynchronously, but on the other hand it makes the simple test look more complicated than it is. There are a few more reasons why I'd keep it:

harkinj commented 5 years ago

Hi, Thanks for your quick response. As u say its not clear which is better but I take on your points. Thanks again John