Chúng tôi đã bắt đầu quá trình tích hợp Reactjs
trong ứng dụng Rails 4.1 của chúng tôi. Vấn đề là rất nhiều tính năng đã bị hỏng.Capybara, Poltergeist và Reactjs - 'undefined' không phải là chức năng
Đây là ngăn xếp cho các bài kiểm tra:
- Dưa chuột
- Capybara
- Poltergeist (thông qua phantomjs)
- RSpec
Ví dụ, có các tính năng dưa chuột:
@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 |
Khi tôi chạy thử nghiệm này sau đó tôi thấy lỗi này:
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 không có 'Function.prototype.bind'. Bạn sẽ cần một [shim] (https://github.com/ariya/phantomjs/issues/10522#issuecomment-39248521), nhưng tôi không biết làm thế nào bạn sẽ sử dụng shim cho ngăn xếp công nghệ cụ thể của bạn. Liên quan: [bind polyfill for PhantomJS] (http://stackoverflow.com/questions/24224323/bind-polyfill-for-phantomjs). Trong CasperJS bạn sẽ làm điều này như [this] (http://stackoverflow.com/questions/25359247/casperjs-bind-issue). Nếu bạn tìm thấy câu trả lời, đừng quên trả lời câu hỏi của riêng bạn. –