reactjs - react-dnd + proxyquire -> Invariant Violation: Could not find the drag and drop manager in the context MyComponent -
i've been using proxyquire stub out sub-components , stores ran invariant violation components wrapped in react-dnd contexts.
warning: failed context types: required context dragdropmanager not specified in dragsource(card). error: invariant violation: not find drag , drop manager in context of card. make sure wrap top-level component of app dragdropcontext. read more: http://gaearon.github.io/react-dnd/docs-troubleshooting.html#could-not-find-the-drag-and-drop-manager-in-the-context
i put repo demonstrate error: see https://github.com/cmelion/react-hot-boilerplate/tree/invariant-violation-dnd
to run execute
npm install npm test
while don't understand why, setting "stub['@global'] = true" on stub returned proxyquire triggered invariant violation.
not setting @global prevents react.testutils working correctly, again not sure why.
the final solution combination of using boolean conditionally set @global , falling good-old queryselectorall.
const subcomponent = react.finddomnode(comp).queryselectorall('.simple-subcomponent'); should(subcomponent.length).equal(1);
the repo has been updated test cases illustrate difference between "normal" proxyquire stub , "special" case.
Comments
Post a Comment