Babel 6-> 7: ошибка неизвестна: неожиданный токен (оператор распространения) - PullRequest
0 голосов
/ 30 марта 2019

Я мигрирую с babel 6 на babel 7. Я получаю некоторые ошибки, которые не могу исправить.

unknown: неожиданный токен (хотя я использую @ babel / plugin-offer-object-rest-распространение).

Эта проблема возникает, когда я запустил комплект модульных тестов Jest.

Журнал ошибок:

 ► yarn run test:unit
yarn run v1.13.0
$ jest --clearCache && jest --coverage=false
Cleared /tmp/jest_rs
 FAIL  test/unit/store.test.js
  ● Test suite failed to run

    unknown: Unexpected token (55:10)

      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://jestjs.io/docs/en/configuration.html
      Details:
      unknown: Unexpected token (55:10)
        53 |       mainMenu: [
        54 |         {
      > 55 |           ...this.$store.state.routes.home,
           |           ^
        56 |           type: Utils.MenuRecordType.PAGE,
        57 |           name: this.$t(`main_menu.${this.$store.state.routes.home.key}`),
        58 |           children: []

My babel.config.jsа мой jest.config.js.(Не публикуйте здесь из-за ограничения stackoverflow (слишком много кода в вашем сообщении…)).

Весь код можно найти на github .

...