离子单元测试地理定位失败

时间:2016-07-28 15:11:04

标签: node.js intellij-idea ionic-framework cordova-plugins ionic2

添加地理位置测试用例后,尝试对我的新离子2应用程序进行单元测试失败。以下是最低示例:https://github.com/geoHeil/ioni2GeolocationUnitTest

运行npm test

可以重现错误
TypeScript error: app/services/geo/geolocation.service.spec.ts(30,38): Error TS2339: Property 'Coordinates' does not exist on type 'typeof ".../node_modules/ionic-native/dist/plugins/geolocation"'.
奇怪的是,即使我指定了:

import  * as NativeGeo  from 'ionic-native/dist/plugins/geolocation';

似乎使用了这种类型定义

/Applications/IntelliJ\ IDEA\ 2016.2\ EAP.app/Contents/plugins/JavaScriptLanguage/typescriptCompiler/external/lib.d.ts

修改

我刚发现Geolocation unit test with JsTestDriver可能与此有点相关

1 个答案:

答案 0 :(得分:0)

我修复了它创建自己的坐标实现,如:

class MyCoordinates implements Coordinates {
    latitude: number;
    longitude: number;
    accuracy: number;
    altitude: number;
    altitudeAccuracy: number;
    heading: number;
    speed: number;
}