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

[Doc] Fix examples of ra-test with fake dataProviders #6600

Merged
merged 1 commit into from
Sep 21, 2021

Conversation

DjebbZ
Copy link
Contributor

@DjebbZ DjebbZ commented Sep 20, 2021

You helped me in #6597, so I figured I could make the docs better for future me and everyone.

I haven't tested the code to see if it works. Also, a few notes:

  • contrarily to some test I've seen in the react-admin code base, I didn't need the await act(async () => await new Promise(r => setTimeout(r))); dance. It seems that simply awaiting was enough to follow properly the event loop.
  • I've simplified the jest.fn().resolve since the examples weren't using the mocked function for some assertions
  • I've replace queryBy with findBy which is the asynchronous equivalent. In my own code, it's required or the rendered content is the inital one before the dataProvider was called.

Feel free to adjust the code before merging, there's no guarantee it's correct in the context of the examples.

@DjebbZ
Copy link
Contributor Author

DjebbZ commented Sep 20, 2021

Furthermore, .resolve() doesn't exist on jest.fn().

@fzaninotto fzaninotto merged commit 79d45c7 into marmelab:master Sep 21, 2021
@fzaninotto
Copy link
Member

Excellent, thanks!

@fzaninotto fzaninotto added this to the 3.18.2 milestone Sep 21, 2021
@fzaninotto fzaninotto changed the title Fix examples of ra-test with fake dataProviders [Doc] Fix examples of ra-test with fake dataProviders Sep 21, 2021
@DjebbZ
Copy link
Contributor Author

DjebbZ commented Sep 21, 2021

You're welcome!

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