Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make poltergeist tests easier to debug #433

Open
stardust66 opened this issue Jan 28, 2018 · 5 comments
Open

Make poltergeist tests easier to debug #433

stardust66 opened this issue Jan 28, 2018 · 5 comments

Comments

@stardust66
Copy link
Contributor

stardust66 commented Jan 28, 2018

This should be incorporated into a guide. By using the :poltergeist_debug(#432) driver, you can write page.driver.debug statements in the cucumber step definitions to have it pause and show a browser window with a web inspector hooked up to the tests, in which you can see javascript errors and the DOM. See my PR for more information.

Read more:
https://github.com/teampoltergeist/poltergeist#remote-debugging-experimental
http://www.jonathanleighton.com/articles/2012/poltergeist-0-6-0/

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Jan 28, 2018

Getting a full devtools up seems powerful and flexible. It also takes a bit of learning to know how to activate this, and it's a lot of steps to then actually change and run the tests manually to get the devtools up for debugging.

The second link you gave has a section about just "re-raising" the JavaScript errors in PhantomJS as errors in the overarching test framework (Capybara, so also Cucumber or RSpec tests that depend on Capybara...)
http://www.jonathanleighton.com/articles/2012/poltergeist-0-6-0/#javascript-errors

So, from poltergeist's GitHub Readme:

  • :js_errors (Boolean) - When false, JavaScript errors do not get re-raised in Ruby.

We should set :js_errors => true. Intuitively I think it should be on by default, so investigating whether that is already working, or how to get it working, would be worthwhile IMO.

I think that would be more seamless, and quicker, but less powerful than a full devtools/remote debugging. I can't really figure out what this next paragraph of the post means, but it sounds like that nice :js_errors feature gets disabled if :inspector => true. Again, it would be worth testing out these options before merging, IMO.

If you setup Poltergeist with the :inspector => true option (see the docs for details), PhantomJS will get set up in remote debugging mode. Note that due to internal WebKit reasons, we can’t report Javascript stack traces in this mode (but that’s okay, because you can see the stack traces in your inspector window).

Looking forward to trying this out over the next couple of days and/or as I get time...

@stardust66
Copy link
Contributor Author

Your intuition is correct that :js_errors => true is on by default. See this line in the travis logs of my map detail PR. In those particular tests however, the stack trace wasn't very helpful. I don't think we have to worry about not having them when remote debugging is turned on because we get the javascript errors in the web inspector instead.

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Jan 30, 2018

I think trying is the only way to find out, so we'll just see how it goes.

EDIT: Posted too early, meant to add another sentence:

My point was just, what if the JS errors being easily (lazily?) viewable is more worthwhile? But honestly we won't know what's worth what or which is better until we've tried both.

@stardust66
Copy link
Contributor Author

I think it's a good idea to write about this in the Wiki. Where would be a good place?

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Feb 10, 2018

Good idea. I'd say this could be added in articles about the existing testing frameworks:

https://github.com/RefugeRestrooms/refugerestrooms/wiki/What-is-Cucumber%3F-What-is-Test-Driven-Design%3F

https://github.com/RefugeRestrooms/refugerestrooms/wiki/What-is-RSpec%3F-How-do-I-create-unit-tests-for-Ruby-code%3F

Or in its own, new article. If you do make it its own article, that article can get a brief mention and a link from the articles about testing frameworks. I'd recommend that approach. But whatever is readable and discoverable are kind of two of the guiding principles of the Wiki as of yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants