Questions tagged [jsdom]

Implementation of the WHATWG DOM and HTML Standards (among others) for node.js

jsdom allows construction of in-memory and in-process objects that represent the window, document, etc. from a browser. It tries to implement the latest DOM and HTML standards, among many others like the CSSOM.

820 questions
0
votes
2 answers

How to execute an external script in jsdom

I have a method in a products.js file like so: var handler = function(errors, window) {...} and would like to execute it within a jsdom env callback: jsdom.env({ html : "http://dev.mysite.com:3000/products.html", scripts : […
Jeff Lowery
  • 2,492
  • 2
  • 32
  • 40
0
votes
1 answer

unable to install jsdom in ubuntu

$ sudo npm install jsdom npm http GET https://registry.npmjs.org/jsdom npm http 304 https://registry.npmjs.org/jsdom .... contextify@0.1.3 install /home/sadchandra/node_modules/jsdom/node_modules/contextify node-gyp rebuild make: Entering…
0
votes
1 answer

Requiring d3 in a node project results in jsdom error

I'm really confused as to what is going on here. With d3 2.10.1, the require 'd3' call generates an error about jsdom in this line of d3's index.js: document = require("jsdom").jsdom(""); jsdom was in d3's…
Andrew Mao
  • 35,740
  • 23
  • 143
  • 224
0
votes
2 answers

How can I replicate Chrome's ability to 'resolve' a DOM from bad html?

I'm using cheerio and node.js to parse a webpage and then use css selectors to find data on it. Cheerio doesn't perform so well on malformed html. jsdom is more forgiving, but both behave differently and I've seen both break when the other works…
Trindaz
  • 17,029
  • 21
  • 82
  • 111
0
votes
1 answer

Assignments fail when running on Mac

I have a node.js project that runs fine on Pc and Linux however when running on a Mac (Mountain Lion) the jQuery module doesn't work. any assignment to a property of the window object is ignored. That is if(jQuery){ window.jQuery = jQuery; …
Rune FS
  • 21,497
  • 7
  • 62
  • 96
0
votes
1 answer

Scraping html using [jsdom + qs]

I'm new to using jsdom and querystring. I'm trying to scrape a page for all of the soundcloud track_id's within all of the iframe html tags. The code below logs undefined because the first iframe is not a soundcloud player. How do I... Modify the…
mnort9
  • 1,810
  • 3
  • 30
  • 54
0
votes
2 answers

Get current browser DOM with jsdom?

Is it possible to get the changed/live DOM of a website with jsdom? For example: Client In my test.html file I have a button, which appends new
elements: $('#button').click(function(){ $('body').append('
Zeus
  • 746
  • 4
  • 18
-1
votes
1 answer

How to mock document.documentElement in a Jest test case?

I have a function that simply returns the 'lang' attribute from the document.documentElement as: const getLang = () => document.documentElement.getAttribute('lang'); I need to write a test case for this. Right now I am doing a spy on/mock…
Rutwick Gangurde
  • 4,772
  • 11
  • 53
  • 87
-1
votes
1 answer

querying li elements returns NodeList conitaned nothing but should exist

Thank you for reading. I would appreciate any suggestions or information. What I'm doing I'm making web scraping app JSDOM and axios. Trying to query all of and get href value. Problem Why lists 's length is 0? How can I get…
suzu
  • 1
-1
votes
2 answers

why does the first code work and the second doesn't work?

when I put div.main as a separated condition the code doesn't work
document.querySelector("div.user-panel.main input[name='login']").style.backgroundColor = "red"; //…
-1
votes
1 answer

why I must write the code with four backslashes instead of two?

I want to write the code like that document.querySelector('#foo\bar'); and it does not work