In my Rails app front-end I use JavaScript's Array.includes
method as follows
if (['a', 'b', 'c'].includes('b')) {
// do stuff
It works fine in a live Chrome browser, but my RSpec test is failing. I believe Capybara Webkit doesn't seem to support it?
I can confirm this by pausing the spec with binding.pry
and running
> page.evaluate_script("['a', 'b', 'c'].includes('b')")
=> nil
It returns nil
when it should return true
.
Just out of curiosity I tried this same thing on another Rails app, and miraculously it worked on that app
> page.evaluate_script("['a', 'b', 'c'].includes('b')")
=> true
So I'm scratching my head as to why it would work on one app but not another?
App #1 (Failure)
- Capybara
2.18.0
- Capybara Webkit
1.15.0
- Capybara
App #2 (Success)
- Capybara
2.13.0
- Capybara Webkit
1.14.0
- Capybara
In fact the first app where it failed seems to have a more recent version of Capybara/Webkit..
Thanks!