Jsdom does not load or run external scripts on the page

Submitted from https://github.com/tmpvar/jsdom/issues#issue/127

I will post a minimal test case the next day or so - but I wanted to see if anyone else has a problem - or if (more likely) if I do something stupid.

I am using NodeJS v2.6 on Ubuntu 10.04 AMD64 and jsdom@0.1.23.

var file = readFileSync ("./www/index.html", "utf8"); var window = jsdom.jsdom (file) .createWindow ();

All built-in scripts run, but complain about the lack of variables that should be provided by external scripts.

I tried setting the URL in the parameters, and I tried using the full (http: // ...) URLs in the src attributes,

I tried jQuerify (using the jQuery default path) and it works fine, although it only leads to jQuery and I still miss all the other scripts.

Any pointers before I post the error code / urls?

Thank,

Chris.

+3
source share
2 answers

As with jsdom 0.2.0, this has become much easier. See the Easy Mode section in readme . jsdom.env () will not execute the scripts found on the default page, making what you are trying to do is much easier.

+1
source

I removed all embedded Javascript from the page - fortunately, the page is under my control.

0
source

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


All Articles