基本上,該組件是沒有得到編譯,所以我得到一個Unexpected token <
錯誤,當它運行到<template>
運行玩笑測試
我已經運行下面的命令:
$ npm install --save-dev jest
$ npm install --save-dev vue-jest
$ npm install --save-dev vue-test-utils
我已經出了以下的package.json
:
"scripts": {
"dev": "node build/dev-server.js",
"build": "node build/build.js",
"test": "jest"
},
...
"jest": {
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/vue"
],
"moduleFileExtensions": [
"js",
"vue"
],
"scriptPreprocessor": "index.js"
}
我創建在根目錄下有一個簡單的測試__test__
文件夾:
const Vue = require("vue");
const VueTestUtils = require("vue-test-utils");
Vue.config.debug = true;
Vue.config.async = false;
Vue.use(VueTestUtils.install);
import Hello from '../src/components/Hello.vue'
const Constructor = Vue.extend(Hello)
const vm = new Constructor().$mount()
describe('initial test',() => {
it('should be 1',() => {
expect(1).toBe(1)
})
})
最近,我得到這個錯誤的歡迎,並不太清楚如何配置Vue.js所以它將運行使用編譯器編譯包括:
[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
一直在尋找了一段時間,所以任何幫助,將不勝感激
您應該檢查這個頁面,它解釋的差異,如何設置和運行完整版本的 https://vuejs.org/v2/guide /installation.html –
謝謝,我閱讀了一堆指南,但是在安裝完npm install vue vue-cli – gazayas
後完全忽略了這一點,但配置webpack構建文件後仍然沒有運氣,如果我取得進展,我會更新 – gazayas