thoughtbot / capybara-webkit

A Capybara driver for headless WebKit to test JavaScript web apps
https://thoughtbot.com/open-source
MIT License
1.97k stars 428 forks source link

JavaScript is not running( submission of a ajax backed form renders partial in response) #1051

Closed ChrisCPO closed 6 years ago

ChrisCPO commented 6 years ago

I have a rails 5.1 .4, that I created with suspenders 1.45

I have an app with some failing(well pending tests) (brach)[https://github.com/ChrisCPO/music_app/tree/develop]

see spec/features/search_spec.rb if you look at the screen shots produced they Ajax /Jquery is not working.

jferris commented 6 years ago

That URL is a 404 for me; is music_app a private repository?

Can you paste the test, the JavaScript it's testing, and the failure? Screenshots may also be helpful.

If you enable debug mode, you can see more details about what capybara-webkit is doing, which may identify the issue.

I'm going to close this issue, as I don't have enough information to identify a potential bug, but feel free to continue commenting and asking questions.

twalpole commented 6 years ago

Most likely this is because you're using more modern JS features than QtWebkit supports (ES5)

ChrisCPO commented 6 years ago

@jferris I have made it public. I can get you some screen shots

ChrisCPO commented 6 years ago

This is the results of a form that does uses ajax and jquery. it is simply submitting the form, as normal. rendering the rendered partial in response.

screenshot_2018-01-11-17-40-29 494

twalpole commented 6 years ago

@ChrisCPO As I guessed, you're using ES6 feature 'let' - https://github.com/ChrisCPO/music_app/blob/develop/app/assets/javascripts/search.js#L2 - and maybe others (I stopped looking when I saw let in the 2nd line) which is not supported by any currently released version of QtWebkit (which capybara-webkit compiles against). You either need to stick to maximum ES5 features, or transpile (babel, etc) your JS during asset compilation to be ES5 compatible. If you enabled debug mode (as suggested by @jferris) or set raise_javascript_errors in the driver config - https://github.com/thoughtbot/capybara-webkit#configuration - it should have been immediately clear what the issue was.

ChrisCPO commented 6 years ago

@twalpole Ahh thanks for your help.