Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

MockedProvider not working correctly #4033

Open
romainleduc opened this issue Jul 7, 2020 · 1 comment
Open

MockedProvider not working correctly #4033

romainleduc opened this issue Jul 7, 2020 · 1 comment

Comments

@romainleduc
Copy link

Hello, the MockedProvider class not working correctly for me.

Example with MockedProvider:

describe('SignupForm', () => {
    test('renders without error', () => {
        renderer.create(
            <MockedProvider mocks={[]}>
              <SignupForm onValidation={() => console.log('redirect')} />
            </MockedProvider>,
          );
    });
});

I get the following error:

  ● SignupForm › renders without error

    Invariant Violation: Could not find "client" in the context or passed in as an option. Wrap the root component in an <ApolloProvider>, or pass an ApolloClient instance in via o
ptions.

Example with bad pratice:

describe('SignupForm', () => {
    test('renders without error', () => {
        renderer.create(
            <ApolloProvider client={client}>
                <SignupForm onValidation={() => console.log('redirect')} />
            </ApolloProvider>
        );
    });
});

it works

My reactDOM render:

ReactDOM.render(
    <ApolloProvider client={client}>
        <CookiesProvider>
            <UserAuthProvider>
                <Router>
                    <Routes />
                </Router>
            </UserAuthProvider>
        </CookiesProvider>
    </ApolloProvider>,
    document.getElementById('root')
);

Thanks for you help :)

@manoelneto
Copy link

@KiziKr were you able to solve it?

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

No branches or pull requests

2 participants