DarthJS
@DarthJS

Как исправить ошибку при установке React Jest?

Только начал разбираться в Jest и вот не задача, в самом начале ошибка, не могу найти решение, устанавливал всё по докам и туториалам:

Jest encountered an unexpected token
      This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
      By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
      Here's what you can do:
       • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
       • If you need a custom transformation specify a "transform" option in your config.
       • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
      You'll find more details and examples of these config options in the docs:
      https://facebook.github.io/jest/docs/en/configuration.html
      Details:
         9 | describe('<App />', () => {
        10 |     it('should render App', () => {
      > 11 |         const wrapper = shallow(<App />);
           |                                 ^
        12 |     })
        13 | })


Скорее всего что-то упустил и не настроил, но все же следовал найденному в интернете описанию. Подскажите что не так?
  • Вопрос задан
  • 2634 просмотра
Решения вопроса 1
DarthJS
@DarthJS Автор вопроса
Решено:
не внимательно читал доки и пользовался больше сторонними ресурсами :)

1. добавил файл .babelrc
2. установил npm install --save-dev babel-preset-stage-2
3. установил babel-plugin-transform-export-extensions
4. добавил конфиг в созданный файл в пункте 1
{
    "env": {
    "test": {
      "presets": ["env", "react", "stage-2"],
      "plugins": ["transform-export-extensions"],
      "only": [
        "./**/*.js",
        "node_modules/jest-runtime"
      ]
    }
  }
}
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы