简体   繁体   English

让水豚在Rails中使用vue.js

[英]getting capybara to work with vue.js in rails

I recently added a feature in vuejs and am having trouble testing it. 我最近在vuejs中添加了一个功能,但无法对其进行测试。

I created a spec file for simply visiting the page but anything on my html that has logic such as a v-show does not get rendered in the test. 我创建了一个用于仅访问页面的规范文件,但是在我的html上任何具有诸如v-show逻辑的东西都不会在测试中呈现。 I added an onload to see if it might render 我添加了一个onload,看它是否可以渲染

window.onload = function () {
  new Vue({
    el: 'body',
    ....
  });
}

but upon running the spec I still get multiple vue warnings like this: 但是在运行规范时,我仍然收到多个vue警告,如下所示:

[Vue warn]: Error when evaluating expression "settingIds.includes(setting.id)": TypeError: 'undefined' is not a
function (evaluating 'scope.settingsIds.includes(scope.setting.id)')`

Note: I am using localstorage which some of my view logic depends on and I'm not sure if capybara supports it 注意:我正在使用我的某些视图逻辑所依赖的localstorage,但不确定capybara是否支持它

假设settingsIds是一个数组-包括PhantomJS或IE不支持的ES7方法(您应该运行的最新PhantomJS 2.1.1,支持的是ES5)-您需要不使用ES6 /来重写代码7种方法,将其转码为ES5或使用poltergeist扩展选项进行polyfill

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM