-
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
fix(template): testing helper PoC #2 #316
fix(template): testing helper PoC #2 #316
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I think this implementation is much easier to follow from the developer/consumer perspective. I will create a stacked branch on top of this, and continue this approach. Maybe I will find out if there are any restrictions. :) |
0368d2d
to
7f7df22
Compare
876280f
to
9330de9
Compare
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
In the end I abstracted the first approach because I was struggling the extract the vi.mock from the file as it is hoisted. You can find more information here (https://storyblok.slack.com/archives/C04P3JBHWHW/p1700068753644059) |
7f7df22
to
4bbec28
Compare
What?
This is a different approach. Instead of mocking
postMessage
andaddEventListener
, this actually changescreateFieldPlugin()
.We used to have only
createFieldPlugin()
and now we also haveinternalCreateFieldPlugin()
. TheinternalCreateFieldPlugin()
accepts two more options:postToContainer
listenToContainer
The
createFieldPlugin
calls theinternalCreateFieldPlugin
with those implementations, but in our testing helper, we mock@storyblok/field-plugin
, and replacescreateFieldPlugin
with different implementations ofpostToContainer
andlistenToContainer
.But this requires us to actually export
internalCreateFieldPlugin
from the library, which is not that big of a deal, in my opinion. (of course, we could rename it)Not sure which take I prefer (the previous one and this)
but probably a good food for thought :)