vue-cli3 创建的项目 默认的单元测试报错解决

1.报错消息类似:
shishifanbuxiedeMacBook-Pro:my-cesium-demo shishifanbuxie$ cd /Users/shishifanbuxie/example/my-cesium-demo ; env "CI=vscode-jest-tests" /usr/local/bin/node --inspect-brk=45373 node_modules/jest/bin/jest.js --runInBand example.spec.js --testNamePattern "renders props\.msg when passed"
Debugger listening on ws://127.0.0.1:45373/531b8dbf-bde5-4aa4-a6f4-68936e9fb172
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
FAIL tests/unit/example.spec.js
  ● Test suite failed to run

    /Users/shishifanbuxie/example/my-cesium-demo/tests/unit/example.spec.js:1
    ({"Object.":function(module,exports,require,__dirname,__filename,global,jest){import "core-js/modules/es6.array.iterator";
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    SyntaxError: Unexpected string

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        2.516s
Ran all test suites matching /example.spec.js/i with tests matching "renders props\.msg when passed".
Waiting for the debugger to disconnect...
Killed: 9
2. issues 地址

我使用的解决方案

在项目目录下执行:
npx jest --clearCache

再次运行单元测试 发现正常了

shishifanbuxiedeMacBook-Pro:my-cesium-demo shishifanbuxie$ yarn test:unit
yarn run v1.9.4
warning ../../package.json: No license field
$ vue-cli-service test:unit
 PASS  tests/unit/example.spec.js
  HelloWorld.vue
    ✓ renders props.msg when passed (23ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.031s
Ran all test suites.
✨  Done in 2.62s.

你可能感兴趣的:(vue-cli3 创建的项目 默认的单元测试报错解决)