Closed mikemassari closed 5 years ago
@Michelemassari Hi! I've found that mocking Apollo is quite complex and there are little docs out there for this. Luckily, I've already spent some time in a similar project and managed to do it. I will update this template soon and maybe write some blog post or something.
If you just want to mock the $apollo
object you can pass mocks to vue-test-utils or add a global mock in test/setup.js
(like this).
For anything more complex than that (like properly mocking queries or mutations) I will need some more time to update this boilerplate.
Hey @frandiox. Thanks for the super quick reply!
Could you please give me a quick example of the test/setup.js
mock?
I would just need something very simple for now for my tests to pass and enable my CI deploy.
I would rather not disable all the tests as others are written and needed.
I've tried
returnOptions.mocks.$apollo = {}
with no luck
@Michelemassari I have something like this for vue-i18n: vueTestUtils.config.mocks.$t = key => key
. I guess vueTestUtils.config.mocks.$apollo = { ... }
could work, but not 100% sure.
Hello. I'm trying to write jest test for my Vue components but every apollo query is met with an error like this
Is there any way I can mock the $apollo object?
I've found some tutorials (another one) but don't know how to apply it to this boilerplate. Any help would be greatly appreciated.