jfroom
jfroom

Reputation: 660

Test scroll position with Karma, PhantomJS, Jasmine

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?

Upvotes: 12

Views: 4134

Answers (1)

queuebit
queuebit

Reputation: 180

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.

Upvotes: 7

Related Questions