Fix jest tests broken with apollo metadata client (#4728)
The tests were broken. It turns out that it is not easy to mock two apolloClients as apollo only provides "MockedProvider" component to mock apollo in tests. MockedProvider Api does not allow us to mock on client level. For now, I'm defaulting to the base ApolloClient in test mode to avoid the issue
This commit is contained in:
@ -1,9 +1,15 @@
|
||||
import { useContext } from 'react';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { ApolloMetadataClientContext } from '../context/ApolloClientMetadataContext';
|
||||
|
||||
export const useApolloMetadataClient = () => {
|
||||
const apolloMetadataClient = useContext(ApolloMetadataClientContext);
|
||||
const apolloClient = useApolloClient();
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
return apolloClient;
|
||||
}
|
||||
|
||||
return apolloMetadataClient;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user