mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Ignore Poltergeist JavaScript Errors as a rails til.
This commit is contained in:
@@ -87,6 +87,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
- [Capybara Page Status Code](rails/capybara-page-status-code.md)
|
- [Capybara Page Status Code](rails/capybara-page-status-code.md)
|
||||||
- [Conditional Class Selectors in Haml](rails/conditional-class-selectors-in-haml.md)
|
- [Conditional Class Selectors in Haml](rails/conditional-class-selectors-in-haml.md)
|
||||||
- [Creating Records of Has_One Associations](rails/creating-records-of-has-one-associations.md)
|
- [Creating Records of Has_One Associations](rails/creating-records-of-has-one-associations.md)
|
||||||
|
- [Ignore Poltergeist JavaScript Errors](rails/ignore-poltergeist-javascript-errors.md)
|
||||||
- [Pretend Generations](rails/pretend-generations.md)
|
- [Pretend Generations](rails/pretend-generations.md)
|
||||||
- [Retrieve An Object If It Exists](rails/retrieve-an-object-if-it-exists.md)
|
- [Retrieve An Object If It Exists](rails/retrieve-an-object-if-it-exists.md)
|
||||||
- [Select Value For SQL Counts](rails/select-value-for-sql-counts.md)
|
- [Select Value For SQL Counts](rails/select-value-for-sql-counts.md)
|
||||||
|
|||||||
21
rails/ignore-poltergeist-javascript-errors.md
Normal file
21
rails/ignore-poltergeist-javascript-errors.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Ignore Poltergeist JavaScript Errors
|
||||||
|
|
||||||
|
Poltergeist with PhantomJS (<2.0) does not support JavaScript's `bind()`
|
||||||
|
method. This means that when executing an integration test that exercises
|
||||||
|
JavaScript with the `bind()` method, an error will occur. If you cannot
|
||||||
|
simply upgrade to a version of PhantomJS that supports `bind()`, then what
|
||||||
|
can you do?
|
||||||
|
|
||||||
|
Ignore the error!
|
||||||
|
|
||||||
|
This can be achieved by placing the following rescue block in the
|
||||||
|
appropriate place.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
rescue Capybara::Poltergeist::JavascriptError
|
||||||
|
```
|
||||||
|
|
||||||
|
Use this in moderation. You want to make sure you don't ignore actual
|
||||||
|
JavaScript errors.
|
||||||
|
|
||||||
|
[source](http://stackoverflow.com/questions/22020680/temporarily-set-js-errors-to-false-in-poltergeist)
|
||||||
Reference in New Issue
Block a user