ERROR: '[Vue warn]: Failed to resolve directive: in testing
ERROR: '[Vue warn]: Failed to resolve directive: in testing
我正在使用 PhantomJS、Karma、Mocha 和 Chai 在 Vue 2.0 应用程序中编写单元测试,当测试通过时,我收到每个测试的警告,如下所示:
ERROR: '[Vue warn]: Failed to resolve directive: highlightjs
(found in <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.
其他测试仍然通过,但当它们全部完成时会出现此错误 运行。已尝试卸载/重新安装节点模块,以及切换节点版本。
呸!已解决:
import VueHighlightJS from 'vue-highlightjs'
Vue.use(VueHighlightJS);
我找到了问题 here 的答案。顺便说一下,我正在苦苦挣扎的组件的创建者的博客 post。看起来您需要在每个单独的测试文件中使用 Vue.use() 包含自定义组件。
我正在使用 PhantomJS、Karma、Mocha 和 Chai 在 Vue 2.0 应用程序中编写单元测试,当测试通过时,我收到每个测试的警告,如下所示:
ERROR: '[Vue warn]: Failed to resolve directive: highlightjs (found in <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.
其他测试仍然通过,但当它们全部完成时会出现此错误 运行。已尝试卸载/重新安装节点模块,以及切换节点版本。
呸!已解决:
import VueHighlightJS from 'vue-highlightjs'
Vue.use(VueHighlightJS);
我找到了问题 here 的答案。顺便说一下,我正在苦苦挣扎的组件的创建者的博客 post。看起来您需要在每个单独的测试文件中使用 Vue.use() 包含自定义组件。