离子单元测试地理定位失败
Ionic unit testing geolocation fails
添加地理定位测试用例后尝试对我的新 ionic2 应用程序进行单元测试失败。这是一个最小的例子: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 可能有点相关
我修复了它,创建了我自己的坐标实现,例如:
class MyCoordinates implements Coordinates {
latitude: number;
longitude: number;
accuracy: number;
altitude: number;
altitudeAccuracy: number;
heading: number;
speed: number;
}
添加地理定位测试用例后尝试对我的新 ionic2 应用程序进行单元测试失败。这是一个最小的例子: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 可能有点相关
我修复了它,创建了我自己的坐标实现,例如:
class MyCoordinates implements Coordinates {
latitude: number;
longitude: number;
accuracy: number;
altitude: number;
altitudeAccuracy: number;
heading: number;
speed: number;
}