Joel Whalen
02/23/2024, 12:15 AMMockedProvider
apollo client component for writing consumer tests? I see in the example that there is an ApolloClient
defined, but for my use case, I'm writing these tests in a separate package that doesn't instantiate an ApolloClient
anywhere; all the unit tests for this interface look kinda like this (using react testing library):
render(
<MockedProvider mocks={mocks} addTypename={false}>
<TestComponent />
</MockedProvider>
);
const results = screen.getByText(/queryResults/i);
expect(results).toHaveTextContent('true');
where the actual request I want to write a contract for is being done inside of TestComponent
when it's rendered in the context of MockedProvider
. It would be nice if the MockedProvider
api had a url prop, but it doesn't. Is there a clean way to render this test component in the context of the pact mock server? Or do I need to instantiate my own custom ApolloClient
and pass it the mock server url, even though this isn't exactly how the underlying app code works?Joel Whalen
02/23/2024, 8:28 PMMatt (pactflow.io / pact-js / pact-go)