pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.41k stars 290 forks source link

Unit testing - gltfjsx created components #259

Open Marlinxx opened 1 month ago

Marlinxx commented 1 month ago

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?