12

I'm using Karma with Jasmine configured with the PhantomJS browser as detailed in browser section of Karma's config docs.

I'm testing a scroll behavior in the page by inspecting the $('body,html').scrollTop() value.

This works fine in Chrome. However, in PhantomJS the window size seems to be growing to be the size of the document. From their docs, working with viewport and scrollPosition requires direct phantomJS WebPage API usage.

Is there a way in Karma spec scripts to access the PhantomJS page object?

Community
  • 1
  • 1
jfroom
  • 660
  • 7
  • 17
  • fwiw - i'm now using a [better method for assessing scroll top](http://stackoverflow.com/questions/871399/cross-browser-method-for-detecting-the-scrolltop-of-the-browser-window). But the Phantom issue described is unrelated to this. – jfroom Oct 22 '13 at 21:04
  • 1
    I am having the same issue. I wish there is a settings option for PhantomJS – Joon Feb 16 '14 at 08:01

1 Answers1

7

A Karma contributor basically says in this this Github Issue to not use Karma for integration-level tests that would require dealing with the page variable.

vojtajina commented 3 months ago

You can't access page variable - the Angular scenario runner tests run IN THE BROWSER and there is no page variable.

The page variable is available in the phantomjs script (that you write to control the phantomjs browser). If you wanna use PhantomJS and its DSL for writing high level tests, just use PhantomJS without Angular scenario runner.

vojtajina commented 3 months ago

Nope, just use PhantomJS without Karma. Karma is for unit testing.

Community
  • 1
  • 1
queuebit
  • 180
  • 1
  • 7