Skip to content

Unit tests failing with material-table/core 4.1.0. #300

@debajit-saha

Description

@debajit-saha
  • I am using Jest and Enzyme to write unit test cases for react app. In those unit test files, where we have import statements for Material Table, the complete test suit is failing. The error message provided by Jest is below:
    Test suite failed to run
    Jest encountered an unexpected token
    This usually means that you are trying to import a file that Jest cannot parse, e.g. it's not plain JavaScript.

  • I checked the next recent version 4..0.0, the issue persists there too. But with version 3.2.5, all tests were passing. See the below screenshot for more detail.

Screenshots
(Image 1)
unit_test_fail2

(Image 2)
image

As the error message suggests possible solutions for the failing tests. I applied 2nd point from the "what you can do" section (Image 2) and added "material-core/table" in the transformIgnorePatterns property in the package.json file. The tests are passing with this change.
So, why do we need to add it to transformIgnorePatterns for tests to work?

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: NA
  • React version: 16.13.1
  • Material-Table/Core - 4.0.1
  • Jest: 26.6.3

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions