vendredi 11 août 2017

Jest throws error Unexpected token function when trying to import component

I am trying to test a basic react component with Jest, but it breaks when I try to import the component.

test.js

import React from 'react';
import {shallow} from 'enzyme';
import Component from '../components/component';


describe('Component', () => {

    it('renders the player component', () => {

        expect(true).toBe(true)

    });


});

.babelrc

{
  "presets": ["es2015", "react"]
}

package.json jest config:

"jest": {

    "setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",

    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "json",
      "jsx"
    ],

    "unmockedModulePathPatterns": [
      "<rootDir>/node_modules/react",
      "<rootDir>/node_modules/react-dom",
      "<rootDir>/node_modules/react-addons-test-utils"
    ]
  }

Aucun commentaire:

Enregistrer un commentaire