readQuery & writeQuery undefined in cache when testing with MockedProvider
Intended outcome:
Being able to readQuery within a mutation within MockedProvider.
Actual outcome:
Setting a breakpoint before readQuery shows that readQuery and writeQuery are actually not defined in cache object.
How to reproduce the issue:
My testing code:
const cache = new InMemoryCache();
const component = mount(
<MockedProvider mocks={mocks} cache={cache}>
<SomeContainer name="my-name">
{({add, remove}) => (
<>
<button
id="add-button"
onClick={() => add({name: 'NAME', value: 'app'})}
/>
<button
id="remove-button"
onClick={() => remove({name: 'NAME', value: 'app'})}
/>
</>
)}
</EnvVarContainer>
</MockedProvider>
);
SomeContainer contains a mutation that optimistically updates cache via cache.readCache and cache.writeCache
Version
System: OS: macOS Mojave 10.14.6 Binaries: Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm Browsers: Chrome: 81.0.4044.138 Firefox: 76.0.1 Safari: 13.1 npmPackages: @apollo/react-testing: ^3.1.4 => 3.1.4 apollo-cache-inmemory: ^1.6.5 => 1.6.5 apollo-client: ^2.6.8 => 2.6.8 apollo-link: ^1.2.14 => 1.2.14 apollo-link-error: ^1.1.13 => 1.1.13 apollo-link-http: ^1.5.17 => 1.5.17 apollo-link-logger: ^1.2.3 => 1.2.3 apollo-upload-client: ^13.0.0 => 13.0.0 react-apollo: ^3.1.5 => 3.1.5