Creating Multiple instance of window object

119 views
Skip to first unread message

Mathew

unread,
Jun 27, 2016, 1:34:57 PM6/27/16
to jsdom
Hi,

Is there a way to create multiple instances of the window object in jsdom after the created callback? My application takes a while to initialize using jsdom.env() so I'm trying to get a copy of the initialized application and work on a copy of the window object per request and even parallel process requests. The problem I'm facing now is the I'll have to wait till on request is completed to start the next one.


Domenic Denicola

unread,
Jun 27, 2016, 1:36:58 PM6/27/16
to js...@googlegroups.com

The best way to do this is to skip using jsdom.env() and just use jsdom.jsom() in combination with your own code that performs the request. You can then call jsdom.jsdom() many times using the same HTML.

--
You received this message because you are subscribed to the Google Groups "jsdom" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsdom+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mathew

unread,
Jun 29, 2016, 12:38:04 AM6/29/16
to jsdom
Thanks Domenic. My app was taking too long to load and I figured the issue out to few external scripts that were timing out. I omitted them and and tried it along with your solutions. Works much better now. I'm getting closer to my solution

Do I have to use the window.close() once I'm done with a request? I'm getting this following error when I do  now 

[TypeError: Cannot read property '_location' of null]

/node_modules/jsdom/lib/jsdom/browser/Window.js:134

      return idlUtils.wrapperForImpl(idlUtils.implForWrapper(window._document)._location);


TypeError: Cannot read property '_location' of null

    at Window.location (/node_modules/jsdom/lib/jsdom/browser/Window.js:134:79)

    at callback (/node_modules/jsdom/lib/jsdom/browser/Window.js:466:40)

    at Timer.listOnTimeout (timers.js:92:15)

Domenic Denicola

unread,
Jun 29, 2016, 12:42:50 PM6/29/16
to js...@googlegroups.com

Can you produce a 10-20 line reproduction case, and post it to the issue tracker? I’ve heard similar issues but nobody has been able to post a small repro.

Reply all
Reply to author
Forward
0 new messages