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

jest not working with react 17 #10814

Closed
TomDlu opened this issue Nov 13, 2020 · 3 comments
Closed

jest not working with react 17 #10814

TomDlu opened this issue Nov 13, 2020 · 3 comments

Comments

@TomDlu
Copy link

TomDlu commented Nov 13, 2020

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 />);
});

@SimenB
Copy link
Member

SimenB commented Dec 30, 2020

The react preset injects import while you use CJS. Adding preset-env or some such should work. If it doesn't, can you put together a repository that works without "runtime": "automatic", but fails with it?

@SimenB
Copy link
Member

SimenB commented Sep 3, 2022

Stale, please open up a new issue if it's still a problem

@SimenB SimenB closed this as completed Sep 3, 2022
@github-actions
Copy link

github-actions bot commented Oct 4, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants