Mocking graphqlLodash with Jest
See original GitHub issueHello,
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:
import React from 'react';
import chai, { expect } from 'chai';
import { shallow } from 'enzyme';
import chaiEnzyme from 'chai-enzyme';
import Foo from './Foo';
describe('Foo', () => {
const shallowed = shallow(<Foo />);
it('test Foo', () => {
{...}
});
});
chai.use(chaiEnzyme());
I have tried multiple ways to mock, but i keep on getting errors.
Thanks 🙂
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Mocking graphqlLodash with Jest · Issue #8 · IvanGoncharov ...
I am trying to mock graphql-lodash with Jest, in order to test components decorated with it. Is there any de-facto / preferred way...
Read more >Mock GraphQL and REST in Storybook and Jest with MSW
Walk through how to mock GraphQL or REST responses at network level, and share mocks between Storybook and Jest tests…
Read more >React-apollo mock provider return no data - Help
i have a component which uses react-apollo graphql function to query data. i am trying to retrieve mock apollo provider using mocked ......
Read more >Mocking | Guide - Vitest
More #. Jest's Mock Functions ... It will let you mock both REST and GraphQL network requests, and is framework agnostic.
Read more >Mocking a lodash function with Jest - Today I Learned
Jest is a framework for testing JavaScript. In this, we will do a quick dive into how to mock a function from a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@aperkaz Thanks for example 🎉
@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: