Skip to content

Commit

Permalink
MockedProvider: default connectToDevTools: false
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Oct 16, 2023
1 parent 2e6a6e2 commit d9ed972
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/lucky-coats-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@apollo/client": patch
---

`MockedProvider`: default `connectToDevTools` to `false` in created `ApolloClient` instance.

This will prevent the mocked `ApolloClient` instance from trying to connect to the DevTools, which would start a `setTimeout` that might keep running after a test has finished.
3 changes: 3 additions & 0 deletions src/testing/react/MockedProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface MockedProviderProps<TSerializedCache = {}> {
children?: any;
link?: ApolloLink;
showWarnings?: boolean;
connectToDevTools?: boolean;
}

export interface MockedProviderState {
Expand All @@ -45,10 +46,12 @@ export class MockedProvider extends React.Component<
resolvers,
link,
showWarnings,
connectToDevTools = false,
} = this.props;
const client = new ApolloClient({
cache: cache || new Cache({ addTypename }),
defaultOptions,
connectToDevTools,
link: link || new MockLink(mocks || [], addTypename, { showWarnings }),
resolvers,
});
Expand Down

0 comments on commit d9ed972

Please sign in to comment.