【发布时间】:2014-09-29 14:59:32
【问题描述】:
我们在 Rails 4.1 应用程序中开始了集成 Reactjs 的过程。问题是现在很多功能都被破坏了。
这是用于测试的堆栈:
- 黄瓜
- 水豚
- Poltergeist(通过 phantomjs)
- Rspec
比如有黄瓜功能:
@javascript @services
Feature: Manage Service
Scenario Outline: Publish and archieve
Given the individual user
When I visit services page
And I click on I18n translation for key "views.labels.add"
And I fill service's fields and choose price as "<price>"
And I click on I18n translation for key "<submit_btn>"
Then I should see I18n translation for key "<message>"
And Created service should have 1 tag
Examples:
| submit_btn | price | message |
| views.labels.publish | fixed | views.messages.notices.add.created |
| views.labels.publish | negotiated | views.messages.notices.add.created |
当我运行这个测试时,我看到了这个错误:
One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).
TypeError: 'undefined' is not a function (evaluating 'RegExp.prototype.test.bind(
/^(data|aria)-[a-z_][a-z\d_.\-]*$/
)')
TypeError: 'undefined' is not a function (evaluating 'RegExp.prototype.test.bind(
/^(data|aria)-[a-z_][a-z\d_.\-]*$/
)')
at http://127.0.0.1:53686/assets/application.js:32342
at http://127.0.0.1:53686/assets/application.js:28807 in s
at http://127.0.0.1:53686/assets/application.js:28807
at http://127.0.0.1:53686/assets/application.js:37581
at http://127.0.0.1:53686/assets/application.js:28807 in s
at http://127.0.0.1:53686/assets/application.js:28807
at http://127.0.0.1:53686/assets/application.js:32910
at http://127.0.0.1:53686/assets/application.js:28807 in s
at http://127.0.0.1:53686/assets/application.js:28807 in e
at http://127.0.0.1:53686/assets/application.js:47260
at http://127.0.0.1:53686/assets/application.js:28807
at http://127.0.0.1:53686/assets/application.js:47262 (Capybara::Poltergeist::JavascriptError)
./features/step_definitions/service.steps.rb:16:in `/^the individual user$/'
features/service/new.feature:9:in `Given the individual user'
【问题讨论】:
-
PhantomJS 1.x 没有
Function.prototype.bind。您需要shim,但我不知道您将如何将 shim 用于您的特定技术堆栈。相关:bind polyfill for PhantomJS。在 CasperJS 中,您可以像 this 一样执行此操作。如果您找到答案,请不要忘记回答您自己的问题。
标签: ruby-on-rails capybara phantomjs reactjs poltergeist