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

[Bug] React & Jest/RTL testing issue after upgrade to 9 #9243

Open
1 of 7 tasks
krishamehta903 opened this issue Nov 11, 2024 · 0 comments
Open
1 of 7 tasks

[Bug] React & Jest/RTL testing issue after upgrade to 9 #9243

krishamehta903 opened this issue Nov 11, 2024 · 0 comments
Labels

Comments

@krishamehta903
Copy link

krishamehta903 commented Nov 11, 2024

Description

We recently upgraded our React-based app to using DeckGL 9.0.8 following the upgrade guide in the docs. The application itself works, but one of our test suites now fails with the following error:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of `FloorPlanMap`

FloorPlanMap is a React functional component that includes the DeckGL React component. We are testing our component with Jest/RTL using the RTL render method. We've tried adjusting imports, which is usually where you see this error.

Everything worked and all tests passed when we were using the latest DeckGL 8. Has anyone else run into this issue after upgrading to DeckGL 9?

Flavors

  • Script tag
  • React
  • Python/Jupyter notebook
  • MapboxOverlay
  • GoogleMapsOverlay
  • CartoLayer
  • ArcGIS

Expected Behavior

No response

Steps to Reproduce

import DeckGL from "deck.gl";

<DeckGL layers={[<insert layers here, though this error occurs even if this is empty>]}></DeckGL>

This code works fine in the application with no errors/issues, however when rendering it in a .test.tsx file using jest and react testing library , this error is seen:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Example of test:

import { render } from "@testing-library/react";
 it("should render the map and table", async () => {
    const { container } = render(<FloorplanMap/>);

      const map = container?.querySelector("#floorPlanMap");

      expect(map).toBeInTheDocument();
      expect(map?.tagName).toBe("CANVAS");
    
  });

We are using "jsdom" for our test environment in our jest config file.

Environment

Logs

No response

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

No branches or pull requests

1 participant