Skip to content

React testing library render() fails when rendering NGL stage #33

Description

@JAZZ-FROM-HELL

When attempting to test an app that contains React NGL <Stage/> using React testing library, render() operation fails with error TypeError: Cannot read property 'setParameters' of undefined

See minimal reproduction based on create-react-app and the basic NGL React example here

`
TypeError: Cannot read property 'setParameters' of undefined

  3 |
  4 | test('renders react ngl app', () => {
> 5 |   render(<App />);
    |   ^
  6 |   expect(screen.getByRole('app')).toBeTruthy();
  7 | });
  8 |

  at E_.setParameters (node_modules/ngl/dist/ngl.js:1:1012424)
  at node_modules/react-ngl/src/components/Stage/Stage.tsx:78:13
  at invokePassiveEffectCreate (node_modules/react-dom/cjs/react-dom.development.js:23487:20)
  at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:3945:14)
  at HTMLUnknownElement.callTheUserObjectsOperation (node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)
  at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:338:25)
  at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3)
  at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:221:9)
  at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:94:17)
  at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:231:34)
  at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:3994:16)
  at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:4056:31)
  at flushPassiveEffectsImpl (node_modules/react-dom/cjs/react-dom.development.js:23574:9)
  at unstable_runWithPriority (node_modules/scheduler/cjs/scheduler.development.js:468:12)
  at runWithPriority$1 (node_modules/react-dom/cjs/react-dom.development.js:11276:10)
  at flushPassiveEffects (node_modules/react-dom/cjs/react-dom.development.js:23447:14)
  at Object.<anonymous>.flushWork (node_modules/react-dom/cjs/react-dom-test-utils.development.js:992:10)
  at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1107:9)
  at render (node_modules/@testing-library/react/dist/pure.js:97:26)
  at Object.<anonymous> (src/App.test.js:5:3)
  at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
  at runJest (node_modules/@jest/core/build/runJest.js:404:19)

`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions