I just phantomjs + jasmine + requirejs + saga to test JavaScript codes.
I used the way to mock navigator.geolocation.getcurrentposition
following 0 in
Does phantomJS support geolocations?
My JavaScript code looks like this:
define(function (require) {
'use strict';
var authenticator = {};
var Authenticator = require("clientservice/authenticator/Authenticator");
var webpage = require('webpage');
describe("Request geolocation information", function(){
beforeEach(function(){
webpage.onInitialized = function() {
webpage.injectJs('geolocation.js');
};
authenticator = new Authenticator(configObj);
});
it("will request browser API for getting geolocation information", function(){
authenticator.authenticate(mockController.successHandler);
});
});
Then I got below error when running mvn clean package verify.
- New Session Created: 6246caf0-4e47-11e6-bc1f-bf8e9b2d1d0e [ERROR - 2016-07-20T06:58:38.443Z] Session [6246caf0-4e47-11e6-bc1f-bf8e9b2d1d0e ] - page.onError - msg: Error: Script error for: webpage
Any idea about it?