-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(template): setup vitest for react template #288
feat(template): setup vitest for react template #288
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hello @plitzenberger Thank you very much for your first contribution to Field Plugin! I agree that it'd be better to have vitest included in the template. However, I'd like to learn more from you before we begin to review this PR. Have you already made any (either production or test) field plugin? How would you write tests (and what kind) for your field plugin in real life? As you may know, Field Plugin works with its container (Visual Editor in production), and communicates with it via postMessage. In this test code, there is no corresponding part, so you had to mock the return of the hook. I'd like to avoid extensive mocking in unit tests. Maybe I can do something to mimic the real environment, but before anything, I want to hear how you'd write tests for yours if you don't mind sharing :) |
Hi @eunjae-lee, Thanks for taking your time. I'm just starting and working on my first custom field-type plugin. My goal is to avoid dealing with I agree; the mocking is quite cumbersome. It might be great to build some |
Hey @plitzenberger Sorry it took longer to get back to you than expected. I've been thinking about this idea, and here's some high-level sketch. Although
What do you think? It's going to take some time to roll it out, so I'm going to merge this PR as-is, since it's already a good addition to the template :) |
@all-contributors please add @plitzenberger for code |
I've put up a pull request to add @plitzenberger! 🎉 |
Hey @eunjae-lee, I love the sketch! And thanks for merging. |
Thanks! Have a great weekend :) |
What?
Setup
vitest
for the react example field-type pluginWhy?
As a developer, I love to write tests so that nobody can mess with my code, and my pipeline will tell me if so.
How to test? (optional)
run
npx @storyblok/field-plugin-cli@beta
and selectreact
template. After completion, runyarn test
in your plugin directory.