首页 > 解决方案 > Vue 未在测试中加载(黄瓜/水豚)

问题描述

我正在用黄瓜测试我的包含 vue 对象的 RoR 应用程序。在浏览器中一切正常,但在测试中未加载 vue。我试图增加水豚的等待时间,但没有奏效。请指出我的地方。

我明白了: 这是页面在测试中的外观

我要测试的代码是

#student_profiles.nomargin
  = render "header"
  .container-fluid.nopadding
    .student_count.aside-wrap.rounded-corners
      %text v-bind:students-count="studentsCount"
      %p.text Sie können aktuell aus <b>{{studentsCount.count}}</b> 
      Schülerinnen und Schülern aus bis zu 50 Ländern wählen.</p>
    .filters.aside-wrap
      %h4 Verfeinern Sie Ihre Auswahl durch Filtern: <filters :filters="filters" :filter-params="filterParams" :load-limit="loadLimit" :students="students" :counter="counter" :hobbies="hobbies" :update="update" :filter-loaded="filterLoaded"></filters>
      %br
      %text v-bind:students-count="studentsCount"
      %p.text Es werden <b>{{studentsCount.count_filter}}</b> von <b>{{studentsCount.count}}</b> angezeigt.</p>
      %br

我使用的步骤是:

@javascript
Scenario: Happy path to bla-bla
  Given I am on a mobile device
  Given I have '6' students shown in the app
  And I visit 'url'
  And I wait for the ajax request to finish
  Then I should see "6" within ".student_count"

对于步骤,Given I have '6' students shown in the app我有以下步骤定义。

Given(/^I have '(\d+)' students shown in the app$/) do |student_count|
  student_count.to_i.times do
    student = FactoryBot.create(:ib_student)
    FactoryBot.create(:ib_student_profile, student: student, force_profile_visible: true)
  end
end

标签: javascriptruby-on-railsrubyvuejs2cucumber

解决方案


对我有用的事情是将我们的整个测试套件切换到 Selenium headless-chrome 而不是 Poltergeist/Phantom JS。


推荐阅读