-
Notifications
You must be signed in to change notification settings - Fork 13
How to test? #4
Comments
I have the same problem but found a workaround. I am using jest's mock feature and mocking state_tunnel, but state_tunnel is completely a copy paste of the TSX file right into my @simonhaenisch I think the reason why this is happening is jest is pulling in the transpiled version instead of the version that you pull in from source. This is because from my experience the transpilation plugins used for jest are usually different then the ones compiled for builds. You might be able to get around this using Ideally, we would probably want to fix this issue by diving a bit more into whats going on with transpilation specifically in the realm of jest. |
@MattMcFarland Would you mind sharing how you managed to mock the state_tunnel? I stumbled upon the same issue. |
@joelalejandro so jest will automatically mock any modules you put in your
|
@MattMcFarland would that also work if the |
@MattMcFarland Could you share a screenshot or another example of the folder structure? It seems to not be working for me. |
@simonhaenisch I don't think it should, but it might if you put it in a yarn workspace root and run all your tests from the root. More info here: https://jestjs.io/docs/en/manual-mocks |
@jthoms1 It'd be nice that this issue becomes the foundation for a doc entry regarding tests on State Tunnels, what do you think? |
I think you might be able to try this: https://github.com/ionic-team/stencil/blob/master/package.json#L157-L159 Looks like they expose their mock functions but I'm not exactly sure why or if it would work. Also this might be worth a gander: jestjs/jest#4262 |
* move nav content into resuable component * group components * add app-modal * add basic modal * make login/register plain routes * merge fix * remove .orig file * add registration form * add deposit and account edit forms * add exchange * more meaningful component names * lint fix * reset pupper version lock * remove DepositChangeset * lint fix again * add app state * display network name * Delete unneeded merge files * lint: Fix errors in widget-connection * Add state-tunnel mock to fix testing issue: ionic-team/stencil-state-tunnel#4 * fix: Fix header-content widget connection connected -> network
There are some changes in stencil coming soon that should make testing this very easy. Once they are released I will add a section to the Wiki on how to test. Leaving this open to track the documentation updated that will be needed. |
* move nav content into resuable component * group components * add app-modal * add basic modal * make login/register plain routes * merge fix * remove .orig file * add registration form * add deposit and account edit forms * add exchange * more meaningful component names * lint fix * reset pupper version lock * remove DepositChangeset * lint fix again * add app state * display network name * Delete unneeded merge files * lint: Fix errors in widget-connection * Add state-tunnel mock to fix testing issue: ionic-team/stencil-state-tunnel#4 * fix: Fix header-content widget connection connected -> network
I think I haven't had any issues with this anymore since Stencil One, so I'm closing this now. |
I have a component
page-first.tsx
with a tunnel
state-tunnel.tsx
and a spec
page-first.spec.tsx
When I run the test, I get this error from the
state-tunnel.tsx
file:Any hints on why this happens?
The text was updated successfully, but these errors were encountered: