Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 意外标识符Jest Vue SVG_Unit Testing_Vue.js_Jestjs - Fatal编程技术网

Unit testing 意外标识符Jest Vue SVG

Unit testing 意外标识符Jest Vue SVG,unit-testing,vue.js,jestjs,Unit Testing,Vue.js,Jestjs,在我的Vue上运行jest时出现此错误。我运行jest命令,得到下面的错误 如果我删除组件中的svg元素。很好用 错误消息 FAIL test/Header.spec.js ● Test suite failed to run /Users/jakzaizzat/Code/taiger/kwa/kcp-admin-ui/node_modules/@babel/runtime-corejs2/helpers/esm/defineProperty.js:1 ({"Objec

在我的Vue上运行jest时出现此错误。我运行
jest
命令,得到下面的错误

如果我删除组件中的
svg
元素。很好用

错误消息

 FAIL  test/Header.spec.js
  ● Test suite failed to run

    /Users/jakzaizzat/Code/taiger/kwa/kcp-admin-ui/node_modules/@babel/runtime-corejs2/helpers/esm/defineProperty.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import _Object$defineProperty from "../../core-js/object/define-property";
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^

    SyntaxError: Unexpected identifier

      19 |             />
      20 |             <path
    > 21 |               d="M15.9999 0L0 8.5541V8.77758V27.0448L16.0001 35.5984L32 27.045V8.5541L15.9999 0ZM16.4239 25.007L18.6367 26.3025L21.1325 24.9877L21.5461 25.7729L18.614 27.3176L15.9848 25.7781L13.3554 27.3176L10.4233 25.7729L10.8369 24.9877L13.3325 26.3025L15.5364 25.0122L15.5358 22.9129L10.7279 19.9154V16.1301L4.71654 13.6018L5.06044 12.7836L11.6154 15.5405V19.1554H20.353V15.5405L26.908 12.7836L27.2519 13.6018L21.2407 16.1301V19.9155L16.4231 22.9197L16.4239 25.007Z"
         |                                               ^
      22 |               fill="white"
      23 |             />
      24 |           </svg>

<div class="px-4">
        <router-link
          to="/"
          class="logo"
        >
          <svg
            width="32"
            height="36"
            viewBox="0 0 32 36"
            fill="none"
            xmlns="http://www.w3.org/2000/svg"
          >
            <path
              d="M15.9849 22.1472L19.3588 20.043H12.6101L15.9849 22.1472Z"
              fill="white"
            />
            <path
              d="M15.9999 0L0 8.5541V8.77758V27.0448L16.0001 35.5984L32 27.045V8.5541L15.9999 0ZM16.4239 25.007L18.6367 26.3025L21.1325 24.9877L21.5461 25.7729L18.614 27.3176L15.9848 25.7781L13.3554 27.3176L10.4233 25.7729L10.8369 24.9877L13.3325 26.3025L15.5364 25.0122L15.5358 22.9129L10.7279 19.9154V16.1301L4.71654 13.6018L5.06044 12.7836L11.6154 15.5405V19.1554H20.353V15.5405L26.908 12.7836L27.2519 13.6018L21.2407 16.1301V19.9155L16.4231 22.9197L16.4239 25.007Z"
              fill="white"
            />
          </svg>
        </router-link>
      </div>
标题.vue

 FAIL  test/Header.spec.js
  ● Test suite failed to run

    /Users/jakzaizzat/Code/taiger/kwa/kcp-admin-ui/node_modules/@babel/runtime-corejs2/helpers/esm/defineProperty.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import _Object$defineProperty from "../../core-js/object/define-property";
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^

    SyntaxError: Unexpected identifier

      19 |             />
      20 |             <path
    > 21 |               d="M15.9999 0L0 8.5541V8.77758V27.0448L16.0001 35.5984L32 27.045V8.5541L15.9999 0ZM16.4239 25.007L18.6367 26.3025L21.1325 24.9877L21.5461 25.7729L18.614 27.3176L15.9848 25.7781L13.3554 27.3176L10.4233 25.7729L10.8369 24.9877L13.3325 26.3025L15.5364 25.0122L15.5358 22.9129L10.7279 19.9154V16.1301L4.71654 13.6018L5.06044 12.7836L11.6154 15.5405V19.1554H20.353V15.5405L26.908 12.7836L27.2519 13.6018L21.2407 16.1301V19.9155L16.4231 22.9197L16.4239 25.007Z"
         |                                               ^
      22 |               fill="white"
      23 |             />
      24 |           </svg>

<div class="px-4">
        <router-link
          to="/"
          class="logo"
        >
          <svg
            width="32"
            height="36"
            viewBox="0 0 32 36"
            fill="none"
            xmlns="http://www.w3.org/2000/svg"
          >
            <path
              d="M15.9849 22.1472L19.3588 20.043H12.6101L15.9849 22.1472Z"
              fill="white"
            />
            <path
              d="M15.9999 0L0 8.5541V8.77758V27.0448L16.0001 35.5984L32 27.045V8.5541L15.9999 0ZM16.4239 25.007L18.6367 26.3025L21.1325 24.9877L21.5461 25.7729L18.614 27.3176L15.9848 25.7781L13.3554 27.3176L10.4233 25.7729L10.8369 24.9877L13.3325 26.3025L15.5364 25.0122L15.5358 22.9129L10.7279 19.9154V16.1301L4.71654 13.6018L5.06044 12.7836L11.6154 15.5405V19.1554H20.353V15.5405L26.908 12.7836L27.2519 13.6018L21.2407 16.1301V19.9155L16.4231 22.9197L16.4239 25.007Z"
              fill="white"
            />
          </svg>
        </router-link>
      </div>


知道这个问题的原因吗?

您是否直接从命令行运行
jest
?或者您正在使用Vue CLI的npm脚本(
npm run test:unit
)?@tony19我正在使用
jest
commandVue CLI为您设置
jest
,因此直接运行
jest
时您将丢失该配置。@tony19似乎无法运行
npm run test:unit
,命令未在
package.json
脚本中定义
test:unit
脚本通常由Vue CLI添加。您是否正在使用Vue CLI生成的项目?