Babel 6-> 7:错误未知:意外令牌(扩展运算符)

问题描述 投票:1回答:1

我从babel 6迁移到babel7。出现一些无法纠正的错误。

未知:意外令牌(即使我正在使用@ babel / plugin-proposal-object-rest-spread)。

此问题在我运行了最好的单元测试套件时出现。

错误日志:

 ► 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: []

我的babel.config.js和我的babel.config.js。 (由于stackoverflow限制(在您的帖子中有太多代码……),因此不在此处发布。)>

完整代码可在jest.config.js上找到。

我从babel 6迁移到babel7。出现一些我无法纠正的错误。未知:意外的令牌(即使我正在使用@ babel / plugin-proposal-object-rest-spread)。我...

vue.js jestjs babeljs nuxt.js babel-jest
1个回答
0
投票

我在'意外令牌...'上也有类似的问题,这是我的@ testing-library的传播运算符错误。即使在我检查了所有正确应用的插件之后,如jest.config.jsgithub所述,并使用babel.config.js代替.babelrc(由于[C​​0]);错误仍然存​​在。令人困惑的是,Jenkins管道能够成功通过同一提交的测试,而不会出现“意外的令牌错误...”。

© www.soinside.com 2019 - 2024. All rights reserved.