Closed aperkaz closed 6 years ago
Hi @aperkaz, Glad that you like our project 🎉
I am trying to mock graphql-lodash with Jest, in order to test components decorated with it.
Not sure that I understand your use case probably because I never wrote any test for React components 😞 Can you please provide more details? Maybe you can provide a simplified version of your test that reproduces issue?
Hello @IvanGoncharov, Thanks for the reply 🙂 . In my case, it seems that the issues when mocking graphql-lodash where side effects from the wrong mock of other modules 😬
where side effects from the wrong mock of other modules
@aperkaz Phew 😇
BTW. Do you use this package in production? Would be great to see a few examples of your queries if possible? It will help us to understand where to go with future versions.
@IvanGoncharov right now we are using it to transform the results of graphQL queries to a CMS (Contentful) to the right props that our React components require.
Using graphql-lodash
allows to easily change the props to what the stateless components are expecting, and also easy to extend if the props in components are chagned/renamed.
Below I attach an example query:
query getPost($id: ID!) {
post(id: $id) {
photo: postPhoto {
alt: title
src: url
}
headline
subtitle: postPerex
content
author: postAuthor @_(get: "name") {
name
}
date
}
}
@aperkaz Thanks for example 🎉
Hello,
First of all, thanks for the nice project. I am trying to mock
graphql-lodash
with Jest, in order to test components decorated with it. Is there any de-facto / preferred way of mocking it? Below I add my code snippets.Tests:
I have tried multiple ways to mock, but i keep on getting errors.
Thanks :slightly_smiling_face: