Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to mock Types? #13

Open
nealoke opened this issue Nov 2, 2019 · 4 comments
Open

How to mock Types? #13

nealoke opened this issue Nov 2, 2019 · 4 comments

Comments

@nealoke
Copy link

nealoke commented Nov 2, 2019

As the title says, how can I mock a type such as DateTime? 馃槃

const MockedNavBarSubscriber = ({ mockResponse, ...props }) => (
	<ApolloMockedProvider
		customResolvers={{
			DateTime: () => new Date(),
			Query: () => ({ me: () => mockResponse.me, company: () => mockResponse.company })
		}}
	>
		<NavBarSubscriber {...props} />
	</ApolloMockedProvider>
);

image

@benawad
Copy link
Owner

benawad commented Nov 3, 2019

I'm not sure

@baleeds
Copy link
Contributor

baleeds commented Nov 11, 2019

@nealoke you figure this out? I'm hitting the same issue

@nealoke
Copy link
Author

nealoke commented Nov 14, 2019

@baleeds no, I've disabled my test and will look into this again later 馃槩

@JaKXz
Copy link

JaKXz commented Jan 29, 2020

Using React testing library and the latest apollo-mocked-provider (at time of writing), we got it to work with:

  <ApolloMockedProvider
    customResolvers={{
      Date: () => jest.fn(() => new Date()),
      Query: () => ({ ... }),
      Mutation: () => ({ ... }),
    }}
  />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants