Skip to content

Bug: react 17 not working with jest #20245

@TomDlu

Description

@TomDlu

I have updated react to 17 and configured babel to new automatic runtime. Jest stopped working.
Whats the issue here?
image

Code:

  "scripts": {
    "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
  },
  "jest": {
    "roots": [
      "<rootDir>/src"
    ],
    "moduleNameMapper": {
      "\\.(css|scss|sass)$": "identity-obj-proxy"
    },
    "setupFilesAfterEnv": ['./test.js'],
    "transform": {
      "\\.[jt]sx?$": "babel-jest"
    },
    "testEnvironment": "jest-environment-node",
    "modulePaths": [],
  }
import Enzyme from "enzyme";
import Adapter from "enzyme-adapter-react-16";

Enzyme.configure({ adapter: new Adapter() });
{
    "presets": [
      [
        "@babel/preset-react",
        {
          "runtime": "automatic"
        }
      ]
    ]
  }
import { mount } from 'enzyme';

it("renders", () => {
  const wrapper = mount(<div />);
});

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions