Mocking Google Maps in RequireJS for running tests offline -


i using async plugin https://github.com/millermedeiros/requirejs-plugins load google maps api:

define(['async!//maps.google.com/maps/api/js?libraries=places&sensor=false'], function () {     // ... }); 

this has consequence of requiring internet connexion when running unit tests. there way mock or otherwise allow code loads run offline without raising "failed load resource" error?

my solution use empty module in place of google_maps module when running qunit tests.

google_maps.js:

define(['async!//maps.google.com/maps/api/js?libraries=places&sensor=false'], function () {     return window.google; }); 

google_maps_stub.js:

define(function () {     window.google = {};     return window.google; }); 

requirejs_config_qunit.js:

define(['./requirejs_config_development.js'], function () {     requirejs.config({         paths: {             'google_maps': 'js/lib/google_maps_stub'         }     }); }); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -