Is there a way to enable external Javascript as a source for Jasmine?

I am trying to customize jasmine.yml (using pearl pearls) to use jQuery from the Google API instead of loading it locally on my server. I.e:.

src_files: - ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js 

Unfortunately, this does not work, because (according to the comments in the configuration file) it is looking for file paths relative to src_dir. Is it impossible?

thanks

Ruy

+6
source share
3 answers

I ended up writing javascript include via spec helper - in my case a Livereload script:

 document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>'); 

A bit hacked, but it works. You might want to more accurately determine where the script is being inserted.

+3
source

If you use jasmine-rails , you can create your own layouts/jasmine_rails/spec_runner.html and add a remote dependency there.

 !!! 5 %html %head %title Jasmine Specs = stylesheet_link_tag *jasmine_css_files %script(src='//maps.googleapis.com/maps/api/js?sensor=false') = javascript_include_tag *jasmine_js_files %body #jasmine_content = yield 
+1
source

You can use jQuery getScript :

 $.getScript( external_script_url, function( data, textStatus, jqxhr ) { some code to execute after script is loaded }); 

If you also want to enable jQuery from the outside, you should load it this way

 document.write('<script src="http://.../jquery.min.js</script>') 
0
source

Source: https://habr.com/ru/post/898801/


All Articles