Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Enzyme mount "Right-hand side of 'instanceof' is not an object" #1249

Closed
hawkeng opened this issue Apr 11, 2019 · 4 comments
Closed

Comments

@hawkeng
Copy link

hawkeng commented Apr 11, 2019

Bug or feature request?

Bug

Expected behavior

Component should be successfully mounted using Enzyme and test should pass.
The component itself renders with no issues.

Actual behavior

react-beautiful-dnd throws error when trying to mount it using Enzyme's mount.

Steps to reproduce

Clone provided repo, install dependencies and run tests with npm test

What version of React are you using?

16.4.0
(also happens with 16.8.0)

What version of react-beautiful-dnd are you running?

10.1.1
(also happens with 11.0.0-beta.3)

Demo

I wasn't able to run jest tests on codesandbox but here's a repo
https://github.com/hawkeng/react-beautiful-dnd-enzyme-issue

Also possibly related issue

  FAIL  src\ListDragDropPicker.spec.jsx
      ● ListDragDropPicker › Should render

    TypeError: Right-hand side of 'instanceof' is not an object

      at isSvgElement (node_modules/react-beautiful-dnd/dist/react-beautiful-dnd.cjs.js:6553:13)
      at throwIfSVG (node_modules/react-beautiful-dnd/dist/react-beautiful-dnd.cjs.js:6559:5)
      at getDragHandleRef (node_modules/react-beautiful-dnd/dist/react-beautiful-dnd.cjs.js:6569:3)
      at DragHandle.componentDidMount (node_modules/react-beautiful-dnd/dist/react-beautiful-dnd.cjs.js:7787:25)
      at commitLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:14248:22)
      at commitAllLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:15342:7)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:100:14)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)
      at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:126:9)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:36:27)
      at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:138:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:187:29)
      at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:15481:7)
      at completeRoot (node_modules/react-dom/cjs/react-dom.development.js:16496:34)
      at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:16440:9)
      at performWork (node_modules/react-dom/cjs/react-dom.development.js:16358:7)
      at performSyncWork (node_modules/react-dom/cjs/react-dom.development.js:16330:3)
      at requestWork (node_modules/react-dom/cjs/react-dom.development.js:16230:5)
      at scheduleWork$1 (node_modules/react-dom/cjs/react-dom.development.js:16096:11)
      at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:16663:3)
      at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:16690:10)
      at updateContainer (node_modules/react-dom/cjs/react-dom.development.js:16717:10)
      at ReactRoot.Object.<anonymous>.ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:17000:3)
      at node_modules/react-dom/cjs/react-dom.development.js:17140:14
      at unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:16557:10)
      at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:17136:5)
      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:17195:12)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:348:114)
      at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:130:16)
      at mount (node_modules/enzyme/build/mount.js:21:10)
      at Object.it (src/ListDragDropPicker.spec.jsx:19:39)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  ListDragDropPicker
    × Should render (94ms)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        3.279s
Ran all test suites related to changed files.

Watch Usage
 › Press a to run all tests.
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.
  console.error node_modules\fbjs\lib\warning.js:33
    Warning: React does not recognize the `isDragging` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `isdragging` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
        in li (at ListDragDropPicker.jsx:26)
        in DragHandle (created by Draggable)
        in DraggableDimensionPublisher (created by Draggable)
        in Draggable (created by Connect(Draggable))
        in Connect(Draggable) (at ListDragDropPicker.jsx:23)
        in ul (at ListDragDropPicker.jsx:21)
        in DroppableDimensionPublisher (created by Droppable)
        in Droppable (created by Connect(Droppable))
        in Connect(Droppable) (at ListDragDropPicker.jsx:19)
        in ErrorBoundary (created by DragDropContext)
        in DragDropContext (at ListDragDropPicker.jsx:18)
        in ListDragDropPicker (created by WrapperComponent)
        in WrapperComponent

  console.error node_modules\fbjs\lib\warning.js:33
    Warning: React does not recognize the `innerRef` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `innerref` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
        in li (at ListDragDropPicker.jsx:36)
        in DragHandle (created by Draggable)
        in DraggableDimensionPublisher (created by Draggable)
        in Draggable (created by Connect(Draggable))
        in Connect(Draggable) (at ListDragDropPicker.jsx:23)
        in ul (at ListDragDropPicker.jsx:21)
        in DroppableDimensionPublisher (created by Droppable)
        in Droppable (created by Connect(Droppable))
        in Connect(Droppable) (at ListDragDropPicker.jsx:19)
        in ErrorBoundary (created by DragDropContext)
        in DragDropContext (at ListDragDropPicker.jsx:18)
        in ListDragDropPicker (created by WrapperComponent)
        in WrapperComponent

  console.warn node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:3534
    %creact-beautiful-dnd

    %cNo <!doctype html> found.


    We expect a html5 doctype: <!doctype html>
    This is to ensure consistent browser layout and measurement

    More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/doctype.md

    %c👷‍ This is a development only message. It will be removed in production builds. color: #00C584; font-size: 1.2em; font-weight: bold; line-height: 1.5 color: #723874;

  console.error node_modules\react-dom\cjs\react-dom.development.js:14113
    The above error occurred in the <DragHandle> component:
        in DragHandle (created by Draggable)
        in DraggableDimensionPublisher (created by Draggable)
        in Draggable (created by Connect(Draggable))
        in Connect(Draggable) (at ListDragDropPicker.jsx:23)
        in ul (at ListDragDropPicker.jsx:21)
        in DroppableDimensionPublisher (created by Droppable)
        in Droppable (created by Connect(Droppable))
        in Connect(Droppable) (at ListDragDropPicker.jsx:19)
        in ErrorBoundary (created by DragDropContext)
        in DragDropContext (at ListDragDropPicker.jsx:18)
        in ListDragDropPicker (created by WrapperComponent)
        in WrapperComponent

    React will try to recreate this component tree from scratch using the error boundary you provided, ErrorBoundary.

  console.error node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:5299
    %creact-beautiful-dnd

    %cAn error has occurred while a drag is occurring.
    Any existing drag will be cancelled.

    > Right-hand side of 'instanceof' is not an object

    %c👷‍ This is a development only message. It will be removed in production builds. color: #00C584; font-size: 1.2em; font-weight: bold; line-height: 1.5 color: #723874;

  console.error node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:5301
    raw TypeError: Right-hand side of 'instanceof' is not an object
        at isSvgElement (C:\Users\antonio.molina\Desktop\demo\node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:6553:13)
        at throwIfSVG (C:\Users\antonio.molina\Desktop\demo\node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:6559:5)
        at getDragHandleRef (C:\Users\antonio.molina\Desktop\demo\node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:6569:3)
        at DragHandle.componentDidMount (C:\Users\antonio.molina\Desktop\demo\node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:7787:25)
        at commitLifeCycles (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:14248:22)
        at commitAllLifeCycles (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:15342:7)
        at HTMLUnknownElement.callCallback (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:100:14)
        at invokeEventListeners (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\events\EventTarget-impl.js:219:27)
        at HTMLUnknownElementImpl._dispatch (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\events\EventTarget-impl.js:126:9)
        at HTMLUnknownElementImpl.dispatchEvent (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\events\EventTarget-impl.js:87:17)
        at HTMLUnknownElementImpl.dispatchEvent (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\nodes\HTMLElement-impl.js:36:27)
        at HTMLUnknownElement.dispatchEvent (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\generated\EventTarget.js:61:35)
        at Object.invokeGuardedCallbackDev (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:138:16)
        at invokeGuardedCallback (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:187:29)
        at commitRoot (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:15481:7)
        at completeRoot (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16496:34)
        at performWorkOnRoot (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16440:9)
        at performWork (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16358:7)
        at performSyncWork (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16330:3)
        at requestWork (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16230:5)
        at scheduleWork$1 (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16096:11)
        at scheduleRootUpdate (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16663:3)
        at updateContainerAtExpirationTime (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16690:10)
        at updateContainer (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16717:10)
        at ReactRoot.Object.<anonymous>.ReactRoot.render (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:17000:3)
        at C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:17140:14
        at unbatchedUpdates (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16557:10)
        at legacyRenderSubtreeIntoContainer (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:17136:5)
        at Object.render (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:17195:12)
        at Object.render (C:\Users\antonio.molina\Desktop\demo\node_modules\enzyme-adapter-react-16\build\ReactSixteenAdapter.js:348:114)
        at new ReactWrapper (C:\Users\antonio.molina\Desktop\demo\node_modules\enzyme\build\ReactWrapper.js:130:16)
        at mount (C:\Users\antonio.molina\Desktop\demo\node_modules\enzyme\build\mount.js:21:10)
        at Object.it (C:\Users\antonio.molina\Desktop\demo\src\ListDragDropPicker.spec.jsx:19:39)
        at Object.asyncFn (C:\Users\antonio.molina\Desktop\demo\node_modules\jest-jasmine2\build\jasmine-async.js:68:30)
        at resolve (C:\Users\antonio.molina\Desktop\demo\node_modules\jest-jasmine2\build\queueRunner.js:38:12)
        at new Promise (<anonymous>)
        at mapper (C:\Users\antonio.molina\Desktop\demo\node_modules\jest-jasmine2\build\queueRunner.js:31:21)
        at Promise.resolve.then.el (C:\Users\antonio.molina\Desktop\demo\node_modules\p-map\index.js:46:16)
        at process._tickCallback (internal/process/next_tick.js:68:7)

  console.error node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:5299
    %creact-beautiful-dnd

    %cAn error has occurred while a drag is occurring.
    Any existing drag will be cancelled.

    > Right-hand side of 'instanceof' is not an object

    %c👷‍ This is a development only message. It will be removed in production builds. color: #00C584; font-size: 1.2em; font-weight: bold; line-height: 1.5 color: #723874;

  console.error node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:5301
    raw ErrorEvent {
      isTrusted: [Getter],
      [Symbol(impl)]:
       ErrorEventImpl {
         type: 'error',
         bubbles: false,
         cancelable: true,
         message: 'Right-hand side of \'instanceof\' is not an object',
         filename:
          'C:\\Users\\antonio.molina\\Desktop\\demo\\node_modules\\react-beautiful-dnd\\dist\\react-beautiful-dnd.cjs.js',
         lineno: 6553,
         colno: 13,
         error:
          TypeError: Right-hand side of 'instanceof' is not an object
              at isSvgElement (C:\Users\antonio.molina\Desktop\demo\node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:6553:13)
              at throwIfSVG (C:\Users\antonio.molina\Desktop\demo\node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:6559:5)
              at getDragHandleRef (C:\Users\antonio.molina\Desktop\demo\node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:6569:3)
              at DragHandle.componentDidMount (C:\Users\antonio.molina\Desktop\demo\node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js:7787:25)
              at commitLifeCycles (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:14248:22)
              at commitAllLifeCycles (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:15342:7)
              at HTMLUnknownElement.callCallback (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:100:14)
              at invokeEventListeners (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\events\EventTarget-impl.js:219:27)
              at HTMLUnknownElementImpl._dispatch (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\events\EventTarget-impl.js:126:9)
              at HTMLUnknownElementImpl.dispatchEvent (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\events\EventTarget-impl.js:87:17)
              at HTMLUnknownElementImpl.dispatchEvent (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\nodes\HTMLElement-impl.js:36:27)
              at HTMLUnknownElement.dispatchEvent (C:\Users\antonio.molina\Desktop\demo\node_modules\jsdom\lib\jsdom\living\generated\EventTarget.js:61:35)
              at Object.invokeGuardedCallbackDev (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:138:16)
              at invokeGuardedCallback (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:187:29)
              at commitRoot (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:15481:7)
              at completeRoot (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16496:34)
              at performWorkOnRoot (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16440:9)
              at performWork (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16358:7)
              at performSyncWork (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16330:3)
              at requestWork (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16230:5)
              at scheduleWork$1 (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16096:11)
              at scheduleRootUpdate (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16663:3)
              at updateContainerAtExpirationTime (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16690:10)
              at updateContainer (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16717:10)
              at ReactRoot.Object.<anonymous>.ReactRoot.render (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:17000:3)
              at C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:17140:14
              at unbatchedUpdates (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:16557:10)
              at legacyRenderSubtreeIntoContainer (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:17136:5)
              at Object.render (C:\Users\antonio.molina\Desktop\demo\node_modules\react-dom\cjs\react-dom.development.js:17195:12)
              at Object.render (C:\Users\antonio.molina\Desktop\demo\node_modules\enzyme-adapter-react-16\build\ReactSixteenAdapter.js:348:114)
              at new ReactWrapper (C:\Users\antonio.molina\Desktop\demo\node_modules\enzyme\build\ReactWrapper.js:130:16)
              at mount (C:\Users\antonio.molina\Desktop\demo\node_modules\enzyme\build\mount.js:21:10)
              at Object.it (C:\Users\antonio.molina\Desktop\demo\src\ListDragDropPicker.spec.jsx:19:39)
              at Object.asyncFn (C:\Users\antonio.molina\Desktop\demo\node_modules\jest-jasmine2\build\jasmine-async.js:68:30)
              at resolve (C:\Users\antonio.molina\Desktop\demo\node_modules\jest-jasmine2\build\queueRunner.js:38:12)
              at new Promise (<anonymous>)
              at mapper (C:\Users\antonio.molina\Desktop\demo\node_modules\jest-jasmine2\build\queueRunner.js:31:21)
              at Promise.resolve.then.el (C:\Users\antonio.molina\Desktop\demo\node_modules\p-map\index.js:46:16)
              at process._tickCallback (internal/process/next_tick.js:68:7),
         target:
          EventTargetImpl {
            _eventListeners: [Object],
            [Symbol(wrapper)]: [Window],
            [Symbol(DOM SymbolTree)]: [SymbolTreeNode] },
         currentTarget:
          Window {
            _core: [Object],
            _globalProxy: [Circular],
            __timers: {},
            _top: [Window],
            _parent: [Window],
            _frameElement: null,
            _document: [Document],
            _sessionHistory: [Array],
            _currentSessionHistoryEntryIndex: 0,
            _length: 0,
            _virtualConsole: [VirtualConsole],
            length: [Getter],
            window: [Getter],
            frameElement: [Getter],
            frames: [Getter],
            self: [Getter],
            parent: [Getter],
            top: [Getter],
            document: [Getter],
            location: [Getter],
            history: [Getter],
            navigator: [Getter],
            addEventListener: [Function: bound addEventListener],
            removeEventListener: [Function: bound removeEventListener],
            dispatchEvent: [Function: bound dispatchEvent],
            setTimeout: [Function],
            setInterval: [Function],
            clearInterval: [Function: bound stopTimer],
            clearTimeout: [Function: bound stopTimer],
            __stopAllTimers: [Function: bound stopAllTimers],
            postMessage: [Function],
            atob: [Function],
            btoa: [Function],
            FileReader: [Function],
            XMLHttpRequest: [Function],
            ArrayBuffer: [Function: ArrayBuffer],
            Int8Array: [Function: Int8Array],
            Uint8Array: [Function: Uint8Array],
            Uint8ClampedArray: [Function: Uint8ClampedArray],
            Int16Array: [Function: Int16Array],
            Uint16Array: [Function: Uint16Array],
            Int32Array: [Function: Int32Array],
            Uint32Array: [Function: Uint32Array],
            Float32Array: [Function: Float32Array],
            Float64Array: [Function: Float64Array],
            stop: [Function],
            close: [Function],
            getComputedStyle: [Function],
            console: [CustomConsole],
            name: 'nodejs',
            innerWidth: 1024,
            innerHeight: 768,
            outerWidth: 1024,
            outerHeight: 768,
            pageXOffset: 0,
            pageYOffset: 0,
            screenX: 0,
            screenY: 0,
            screenLeft: 0,
            screenTop: 0,
            scrollX: 0,
            scrollY: 0,
            scrollTop: 0,
            scrollLeft: 0,
            screen: [Object],
            alert: [Function],
            blur: [Function],
            confirm: [Function],
            createPopup: [Function],
            focus: [Function],
            moveBy: [Function],
            moveTo: [Function],
            open: [Function],
            print: [Function],
            prompt: [Function],
            resizeBy: [Function],
            resizeTo: [Function],
            scroll: [Function],
            scrollBy: [Function],
            scrollTo: [Function],
            toString: [Function: toString],
            Buffer: [Function],
            process: [Object],
            setImmediate: [Function],
            clearImmediate: [Function: clearImmediate],
            mockRunTicksRepeatedly: [Function: bound runAllTicks],
            mockRunTimersOnce: [Function: bound runOnlyPendingTimers],
            mockRunTimersToTime: [Function: bound runTimersToTime],
            mockRunTimersRepeatedly: [Function: bound runAllTimers],
            mockClearTimers: [Function: bound clearAllTimers],
            mockGetTimersCount: [Function],
            Headers: [Function: Headers],
            Request: [Function: Request],
            Response: [Function],
            fetch: [Function],
            requestAnimationFrame: [Function: raf],
            cancelAnimationFrame: [Function: caf],
            describe: [Function],
            xdescribe: [Function: xdescribe],
            fdescribe: [Function: fdescribe],
            it: [Function],
            xit: [Function: xit],
            fit: [Function],
            beforeEach: [Function: beforeEach],
            afterEach: [Function: afterEach],
            beforeAll: [Function: beforeAll],
            afterAll: [Function: afterAll],
            pending: [Function: pending],
            fail: [Function: fail],
            spyOn: [Function: spyOn],
            jsApiReporter: [JsApiReporter],
            jasmine: [Object],
            test: [Function],
            xtest: [Function: xit],
            expect: [Function],
            '__core-js_shared__': [Object],
            'react-beautiful-dnd-announcement-0': [Getter/Setter] },
         eventPhase: 2,
         _initializedFlag: true,
         _stopPropagationFlag: false,
         _stopImmediatePropagationFlag: false,
         _canceledFlag: false,
         _dispatchFlag: true,
         isTrusted: false,
         timeStamp: 1555012879911,
         [Symbol(wrapper)]: [Circular] } }

  console.error node_modules\react-dom\cjs\react-dom.development.js:14113
    The above error occurred in the <ErrorBoundary> component:
        in ErrorBoundary (created by DragDropContext)
        in DragDropContext (at ListDragDropPicker.jsx:18)
        in ListDragDropPicker (created by WrapperComponent)
        in WrapperComponent

    Consider adding an error boundary to your tree to customize error handling behavior.
    Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
@hawkeng
Copy link
Author

hawkeng commented Apr 11, 2019

FIX

Update: I was able to fix this by adding below line to my setupTests.js file

global.SVGElement = Array;

Note: I use Array here since I'm sure I'm not using SVGs as my handler elements and because I know an element cannot be of type Array. A custom type can also be used.

Explanation
Enzyme's generic window object doesn't contain all of the properties that the real window has.

This is the failing code:

function isSvgElement(el) {
  return el instanceof getWindowFromEl(el).SVGElement;
}

Throws error since Enzyme's window.SVGElement = undefined

I think this should be added to the docs in order to prevent other people from having this issue.

@alexreardon
Copy link
Collaborator

Could we do something on our end to prevent people getting this issue?

@hawkeng
Copy link
Author

hawkeng commented Apr 11, 2019

@alexreardon Maybe documenting this in the common setup issues section could help.

@alexreardon
Copy link
Collaborator

alexreardon commented Apr 11, 2019 via email

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

No branches or pull requests

2 participants