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

Check if queryManager is set before accessing it #2165

Merged
merged 1 commit into from
Jul 6, 2018

Conversation

danilobuerger
Copy link
Contributor

Fixes #2164 . Sorry for breaking the release :(.

@rosskevin rosskevin merged commit e667a99 into apollographql:master Jul 6, 2018
@rosskevin
Copy link
Contributor

Thanks @danilobuerger!

@danilobuerger danilobuerger deleted the 2164 branch July 6, 2018 15:07
@lnmunhoz
Copy link

lnmunhoz commented Aug 1, 2018

This fix was published on 2.1.9?

@stolinski
Copy link

I'm still seeing this TypeError: Cannot read property 'scheduler' of undefined error in 2.1.9.

@danilobuerger
Copy link
Contributor Author

It wasn't released in 2.1.9

danilobuerger added a commit to danilobuerger/react-apollo that referenced this pull request Aug 2, 2018
@carlows
Copy link
Contributor

carlows commented Aug 6, 2018

When is this being released?

@danilobuerger
Copy link
Contributor Author

Was released in 2.1.11

@ashoksudani
Copy link

ashoksudani commented Apr 2, 2019

Hi @danilobuerger

I am getting the error around same scenario

in react-apollo/test-utils.js
MockedProvider.prototype.componentWillUnmount = function () { this.state.client.stop(); };

this.state.client is available but stop is undefined.

This is happening because of cleanup in import 'react-testing-library/cleanup-after-each';

Do you think this should be raised as a new issue OR is there anything I am doing wrong in my setup.

My dependencies :

   {
    "graphql": "0.13.0",
    "graphql-tag": "^2.10.1",
    "react": "^16.8.4",
    "react-apollo": "^2.5.2",
    "react-dom": "^16.8.4",
    "react-router-dom": "^5.0.0",
    "react-scripts": "2.1.8"
  },

I have tried different versions of react-apollo :
It is not working for 2.5.2 , 2.5.3 .. till 2.4.0
But it is working completely all right with from 2.3.3 or 2.1.8 :)

Below is the error :


TypeError: this.state.client.stop is not a function

      at MockedProvider.Object.<anonymous>.MockedProvider.componentWillUnmount (node_modules/src/test-utils.tsx:55:23)
      at callComponentWillUnmountWithTimer (node_modules/react-dom/cjs/react-dom.development.js:17123:12)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:149:14)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
      at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:30:27)
      at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:199:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:256:31)
      at safelyCallComponentWillUnmount (node_modules/react-dom/cjs/react-dom.development.js:17130:5)
      at commitUnmount (node_modules/react-dom/cjs/react-dom.development.js:17507:11)
      at unmountHostComponents (node_modules/react-dom/cjs/react-dom.development.js:17827:7)
      at commitDeletion (node_modules/react-dom/cjs/react-dom.development.js:17858:5)
      at commitAllHostEffects (node_modules/react-dom/cjs/react-dom.development.js:18639:11)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:149:14)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
      at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:30:27)
      at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:199:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:256:31)
      at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:18867:7)
      at node_modules/react-dom/cjs/react-dom.development.js:20372:5
      at Object.unstable_runWithPriority (node_modules/scheduler/cjs/scheduler.development.js:255:12)
      at completeRoot (node_modules/react-dom/cjs/react-dom.development.js:20371:13)
      at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:20300:9)
      at performWork (node_modules/react-dom/cjs/react-dom.development.js:20208:7)
      at performSyncWork (node_modules/react-dom/cjs/react-dom.development.js:20182:3)
      at requestWork (node_modules/react-dom/cjs/react-dom.development.js:20051:5)
      at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:19865:5)
      at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:20526:3)
      at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:20554:10)
      at updateContainer (node_modules/react-dom/cjs/react-dom.development.js:20611:10)
      at ReactRoot.Object.<anonymous>.ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:20907:3)
      at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:21059:12)
      at node_modules/react-dom/cjs/react-dom.development.js:21132:9
      at unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:20413:10)
      at Object.unmountComponentAtNode (node_modules/react-dom/cjs/react-dom.development.js:21131:7)
      at cleanupAtContainer (node_modules/react-testing-library/dist/index.js:108:21)
          at Set.forEach (<anonymous>)
      at Object.cleanup (node_modules/react-testing-library/dist/index.js:102:21)

Below is my code block :

import React from 'react';
import { Query } from 'react-apollo';
import { render } from 'react-testing-library';
import 'react-testing-library/cleanup-after-each';
import { MockedProvider } from 'react-apollo/test-utils';
import wait from 'waait';

import queryGethAllApps from 'graphql/queries/get-all-apps';

function FeatureList({ refetch }) {
  return (
    <Query
      query={queryGethAllApps}
      fetchPolicy={refetch ? 'cache-and-network' : 'cache-first'}
    >
      {({ loading, data: { listFtApplications } }) => {
        if (loading) return <span>loading....</span>;
        return <span>feature lists</span>;
      }}
    </Query>
  );
}

test('It renders feature list component', async () => {
  const mocks = [
    {
      request: {
        query: queryGethAllApps
      },
      result: {
        data: {
          listFtApplications: {
            items: [{ id: '123', name: 'mock test' }]
          }
        }
      }
    }
  ];

  const { getByText, asFragment } = render(
    <MockedProvider mocks={mocks} addTypename={false}>
      <FeatureList />
    </MockedProvider>
  );

  await wait(0);

  expect(asFragment()).toMatchSnapshot();
  expect(getByText('feature lists')).toBeInTheDocument();
});

@sopranolinist
Copy link

Hi @danilobuerger

I am getting the error around same scenario

in react-apollo/test-utils.js
MockedProvider.prototype.componentWillUnmount = function () { this.state.client.stop(); };

this.state.client is available but stop is undefined.

This is happening because of cleanup in import 'react-testing-library/cleanup-after-each';

Do you think this should be raised as a new issue OR is there anything I am doing wrong in my setup.

My dependencies :

   {
    "graphql": "0.13.0",
    "graphql-tag": "^2.10.1",
    "react": "^16.8.4",
    "react-apollo": "^2.5.2",
    "react-dom": "^16.8.4",
    "react-router-dom": "^5.0.0",
    "react-scripts": "2.1.8"
  },

I have tried different versions of react-apollo :
It is not working for 2.5.2 , 2.5.3 .. till 2.4.0
But it is working completely all right with from 2.3.3 or 2.1.8 :)

I am getting this exact same error with react-apollo 2.5.8. Rolling back to 2.3.3 fixed the bug and allowed my tests to run successfully.

@gabsprates
Copy link

Hello @ashoksudani, can you open an issue with your error, please?

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

Successfully merging this pull request may close these issues.

MockedProvider TypeError: Cannot read property 'scheduler' of undefined
8 participants