通过将Jest与Vue结合使用,Jest似乎会阻塞.vue文件中的HTML注释

时间:2019-05-30 08:06:00

标签: vue.js jestjs

下面是我运行Jest时看到的输出:

  ● Test suite failed to run

    /home/ubuntu/chat-app/frontend/node_modules/@babel/runtime-corejs2/helpers/esm/asyncToGenerator.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import _Promise from "../../core-js/promise";
                                                                                                    ^^^^^^^^

    SyntaxError: Unexpected identifier

      11 |                     {{ current_nickname }}
      12 |
    > 13 |                     <!-- https://linearicons.com/free#cdn -->
         |                                                 ^
      14 |                     <span class="lnr-button">
      15 |                         <svg class="lnr lnr-pencil" @click="prompt_nickname()"><use xlink:href="#lnr-pencil" /></svg>
      16 |                     </span>

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:471:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:513:25)
      at src/components/ChatApp.vue:13:49
      at Object.<anonymous> (src/components/ChatApp.vue:219:3)

HTML注释似乎令人窒息。

问题可能是什么?

以下是其他相关的配置文件:

babel.config.js

module.exports = {
  presets: [
    '@vue/app'
  ]
}

jest.config.js

module.exports = {
        moduleFileExtensions: ['js', 'jsx', 'json', 'vue'],
        transform: {
                '^.+\\.vue$': '<rootDir>/node_modules/vue-jest',
                '.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
                'jest-transform-stub',
                '^.+\\.(js|jsx)?$': '<rootDir>/node_modules/babel-jest'
        },
        moduleNameMapper: {
                '^@/(.*)$': '<rootDir>/src/$1'
        },
        snapshotSerializers: ['jest-serializer-vue'],
        transformIgnorePatterns: ['<rootDir>/node_modules/']
};

不确定是什么问题,感谢您的帮助,谢谢。

0 个答案:

没有答案