簡體   English   中英

錯誤:'[Vue警告]:無法解析指令:在測試中

[英]ERROR: '[Vue warn]: Failed to resolve directive: in testing

我正在使用PhantomJS,Karma,Mocha和Chai在Vue 2.0應用程序中編寫單元測試,並且在測試通過時,每條看起來像這樣的測試都會警告我:

錯誤:'[Vue警告]:無法解析指令:highlightjs(在<UnitTest>中找到)

我要么想找到一種方法來忽略有關自定義指令的警告,要么以某種方式使測試意識到它們。

===可能相關,可能是單獨的錯誤===

當我強制其中一項測試失敗時,我得到的錯誤如下:

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "unit"
npm ERR! node v7.6.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! vuestack@1.0.0 unit: `cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vuestack@1.0.0 unit script 'cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vuestack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vuestack
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vuestack
npm ERR! There is likely additional logging output above.

其他測試仍然通過,但在全部運行時都會顯示此錯誤。 嘗試卸載/重新安裝節點模塊,以及切換節點版本。

h! 解決了:
import VueHighlightJS from 'vue-highlightjs' Vue.use(VueHighlightJS);

我在這里找到了問題的答案。 順便說一句,我苦苦掙扎的組件的創建者寫的博客文章。 看起來您需要在每個單獨的測試文件中使用Vue.use()包括自定義組件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM