Jsdom: Disabling same origin policy check

Created on 15 Aug 2017  路  4Comments  路  Source: jsdom/jsdom

I am trying to unit test some ajax calls (written in Scala.js) with jsdom and I would like to disable same origin policy checks.

How can I do that ? I was searching this on the net but found nothing.

Most helpful comment

+1 to @arendjr's suggestion. JSDOM's utility is not only as a browser emulator but also as a testing platform and pretty much anything which makes testing harder has the unfortunate affect of reducing testing. It takes a lot of nock ceremony to work around JSDOM's cross-origin checks which leaves test writers working on code incidental to their intended tests.

All 4 comments

You cannot. jsdom acts like a browser, including same-origin checks.

Make sure you are setting the URL correctly though.

Many thanks for the info.

At least Chrome has a command-line argument to disable CORS checks. Why can't JSDOM provide a developer-friendly way to disable it?

+1 to @arendjr's suggestion. JSDOM's utility is not only as a browser emulator but also as a testing platform and pretty much anything which makes testing harder has the unfortunate affect of reducing testing. It takes a lot of nock ceremony to work around JSDOM's cross-origin checks which leaves test writers working on code incidental to their intended tests.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mitar picture mitar  路  4Comments

philipwalton picture philipwalton  路  4Comments

drewish picture drewish  路  4Comments

domenic picture domenic  路  3Comments

kilianc picture kilianc  路  4Comments