Skip to content

Unit testing - gltfjsx created components #259

@Marlinxx

Description

@Marlinxx

I create the react components form .glb files using gltfjsx package. And I make some changes like adding event handlers and adding refs.
The React component works fine in dev environment. But cannot render the component from unit testing.

Test case:

test("render" , async () => {
  const mechClickHandler = jest.fn();

  const props = {
        position: new Vector3(0, 0, 0),
        slotNumber: 1,
        cardName: "HCPSLine22",
        onMeshClick: mechClickHandler,
        ports: cardData.ports,
        cardType: "HCPSLine22",
        card: cardData,
        expanded: false,
        ejected: false,
      };
  render(<HCPSLine22 {...props} />)
}) 

And Im facing below issue,
TypeError: Cannot destructure property 'nodes' of '(0 , _drei.useGLTF)(...)' as it is undefined.

Aim: I looking to test the events fired from component

Can someone help here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions