samedi 20 juillet 2019

React App with Jest - Jest encountered an unexpected token

I'm trying to test a component using the react-test-renderer library and i'm getting this error. enter image description here

Header.test.js:

 import ReactShallowRenderer from "react-test-renderer/shallow";
import React from "react";
import Header from "../../components/Header/Header";

test("should render Header correctly", () => {
  const renderer = new ReactShallowRenderer();
  renderer.render(<Header />);
  // Returning the render output of the jsx
  console.log(renderer.getRenderOutput());
});

That's my jest config:

"jest": {
"verbose": true,
"transform": {
  "^.+\\.js$": "babel-jest",
  "^.+\\.(css|scss|less)$": "jest-css-modules"
}

My babelrc:

{
  "env": {
    "development": {
      "plugins": ["transform-es2015-modules-commonjs"]
    },
    "test": {
      "plugins": ["transform-es2015-modules-commonjs"]
    }
  }
}

Aucun commentaire:

Enregistrer un commentaire