简体   繁体   中英

JavaScript Integration Testing

I wish to test the full functionality of a particular JavaScript component, which makes a cross-origin ajax call. I am making use of PhantomJS to perform testing without a browser. Is there a way I can mock the origin header in this framework, so that the ajax call succeeds?

There is a command-line switch web-security=false which disables cross-origin check when an ajax call is made in PhantomJS. Use it before the script argument in command line:

/usr/bin/phantomjs --web-security=false /path/to/script.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM