jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

External dependencies are working in browser, but not from CLI #411

Closed lexi-lambda closed 9 years ago

lexi-lambda commented 9 years ago

My application depends on the google maps API, which is being loaded remotely from Google's CDN. I've taken a look at the conversation in #34, and I've added the following to my suite configuration:

suite.javascripts << 'https://maps.googleapis.com/maps/api/js?libraries=geometry,places'

All the tests pass fine in the browser interface, but when I run the CLI, the tests error because window.google (which should be defined by the above remote script) isn't defined.

I'm running the server and the CLI in the same Rails environment, test. The error occurs whether or not I go through Spring, and it occurs whether or not I use the Rake task or the teaspoon executable directly. However, no configuration I've tried has caused the tests to fail in the web UI.

Any ideas on how I can debug this further?

jejacks0n commented 9 years ago

I wonder if google maps doesn't load via phantomjs for some reason... I don't have a quick solve for you, but I'd double check that you're using your correct access tokens? Are they even needed for those apis?

A good thing to check, would be to switch the driver to selenium -- this is pretty easy, and there's a wiki article for it. That would be my first check. If it works, I assume it must be something to do with phantomjs, or that google maps won't load when requested from phantom. If I recall, we may set the client string to something for teaspoon.

lexi-lambda commented 9 years ago

Yes, it appears to be a PhantomJS issue. Thanks! It seems that passing the --ignore-ssl-errors=yes flag fixed the problem, which is obviously preferable over using Selenium.

...however, this did lead to my discovery of a separate problem, which I've noted in issue #413.