所以我将这个模块包含在我的Angular应用程序
https://github.com/angular-ui/angular-google-maps中
现在问题是:如何运行集成它的Karma测试?
Running "karma:unit" (karma) task
INFO [karma]: Karma v0.10.6 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [watcher]: Pattern "/Users/Work/status/test/mock/**/*.js" does not match any file.
INFO [Chrome 31.0.1650 (Mac OS X 10.8.4)]: Connected on socket iLYLgPcHaw8HVJjNNafq
Chrome 31.0.1650 (Mac OS X 10.8.4) ERROR
Uncaught ReferenceError: google is not defined
at /Users/Work/status/app/scripts/angular-google-maps.min.js:6
Chrome 31.0.1650 (Mac OS X 10.8.4): Executed 0 of 0 ERROR (0.509 secs / 0 secs)
Warning: Task "karma:unit" failed. Used --force, continuing.
Done, but with warnings.
所以它缺少全球谷歌对象
我看到了几个解决方案,但不知道如何实现它们:
– 每次我们运行测试时注入google脚本(虽然效率低下).问题是,我如何以及在何处注射它?
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=en"></script>
-i读了一个我们可以模拟谷歌API的建议
最佳答案 已经在项目的问题列表中已经多次询问过这个问题.这是q / a之一.
https://github.com/angular-ui/angular-google-maps/issues/270