dimanche 31 décembre 2017

Babel will not compile .test.js files while running Jest

While running yarn run jest --no-cache, An error is being thrown that says:

SyntaxError: Unexpected token import

My best guess is that babel is not reaching this this test file. Is their something special I need to include in .babelrc?

path:

/src/tests/LandingPage.test.js

test file:

import React from 'react';
import ReactShallowRenderer from 'react-test-renderer/shallow';
import LandingPage from '../../components/LandingPage';

test('Should render LandingPage correctly', () => {
  const renderer = new ReactShallowRenderer();
  renderer.render(<LandingPage />);
  expect(renderer.getRenderOutput()).toMatchSnapshot();
});

.babelrc :

{
  "presets": [
    "env",
    "react"
  ],
  "plugins": [
    "transform-class-properties",
    "transform-object-rest-spread"
  ]
}

Aucun commentaire:

Enregistrer un commentaire