Grunt-contrib-jasmine and PhantomJS security

I get an error

XMLHttpRequest cannot load https://my-api.domain.com . Source file: // not allowed Access-Control-Allow-Origin.

when I try to run some asynchronous unit tests that request an API through grunt-contrib-jasmine, which in turn uses PhantomJS. I see that the PhantomJS command-line version has "web-security" options. Can I control how grunt-contrib-jasmine uses PhantomJS to enable this option and disable cross-domain security?

+7
source share
1 answer

You can pass parameters to phantomjs in the same way as on the command line, for example

The following options may help, but more can be found in the phantomjs docs

jasmine : { your_task : { options : { '--web-security' : false, '--local-to-remote-url-access' : true, '--ignore-ssl-errors' : true } } } 
+15
source

All Articles