-
-
Notifications
You must be signed in to change notification settings - Fork 230
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
Adding a Jest Section to the docs #135
base: master
Are you sure you want to change the base?
Adding a Jest Section to the docs #135
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Directionally I think this is correct, although it is a bit of a solution to a specific use case. Here’s what I mean:
Some thoughts and possible solutions:Although Jest is super popular new "hot" testing packages are growing quickly, so I'm not sure a section specific to Jest is necessary here. So perhaps instead of a top-level section specific to Jest we could rename this "Testing" and explain the ESM limitation of Jest and the JSDom limitation along with a possible mocking options, including the one you’ve provided. Thoughts? |
Alright @justin-schroeder , one of my questions was whether to create a main section or a subsection about this, I understand your point about Jest being a "hot" and popular package, and we might not need that section soon, so yes, it's better to just create a subsection really. I'll rewrite the section focusing on the JSDom issue and try to embrace more packages that use JSDom and have the same problem. And finally, create other examples mocking just the JSDom implementation than all the auto animate as you suggest. What do you think? |
This sounds like great idea @ArthurPedroti — I’ll happily accept that PR. |
… session - add a example to mock the ResizeObserver with jest - add a exmaple to mock the auto-animete hook with Jest
I moved the Jest section to the React Usage section and first I described the JSDom problem and how to handle it, and follow I explain the ESM problem with Jest. Even though I set up my Jest project with the ESM as the documentation of Jest says, I faced some problems and couldn't get it to work. So I maintain the example of the entirely mock of the auto-animate. I know this is not the ideal and the best approach is mock like the Vitest example, but I think Jest has some problems yet to really handle with ESM, but as you said, I think soon the example can be outdated (jestjs/jest#9430), but someway, can be helpful to who don't want to update your Jest setup for now. |
On this theme, have any of you encountered issues with the following error when testing components using this auto-animate whilst testing with vitest:
|
If somebody stuck with ResizeObserver issue vi.mock('@formkit/auto-animate/vue', () => ({
useAutoAnimate: () => [null],
})); does the job. |
Context: #29
@justin-schroeder
Justin, I added a section about how to mock the autoAnimate function and hook with Jest as you suggest.
Make sure the language and approach match the tone of all documentation. If you have any suggestions or want to change something, feel free to do it.
Preview: