【发布时间】:2016-07-20 07:18:28
【问题描述】:
我只是 phantomjs + jasmine + requirejs + saga 来测试 JavaScript 代码。
我用这种方式来模拟navigator.geolocation.getcurrentposition跟随0 in
Does phantomJS support geolocations?
我的 JavaScript 代码如下所示:
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);
});
});
然后在运行 mvn clean package verify 时出现以下错误。
- 已创建新会话:6246caf0-4e47-11e6-bc1f-bf8e9b2d1d0e [错误 - 2016-07-20T06:58:38.443Z] 会话 [6246caf0-4e47-11e6-bc1f-bf8e9b2d1d0e ] - page.onError - msg: Error: Script error for: 网页
有什么想法吗?
【问题讨论】:
-
authenticator.authenticate 调用 navigator.geolocation.getcurrentposition
标签: requirejs jasmine phantomjs navigator saga