jsdom

Nodejs script fails to print after d3.json()?

≡放荡痞女 提交于 2019-12-25 04:08:08
问题 ( Edit: the question have been rewritten to better isolate the issue.) I'am writing a single D3js script.js which could be reused "as it" in both web browser for client side and nodejs for server side uses. I made some good progress : a single d3js script.js indeed create basic svg shapes on both client and server sides. On web browser displaying the viz, on server side outputing the wanted map.svg file. I have a more complex d3js map making code: client side it works like a charm (link) but!

How to test a Webpack bundle that has external dependencies?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 20:12:07
问题 I'm new to Webpacker and Rails in general. I recently moved to using Webpacker to bundle React components. Since part of the application still uses the asset pipeline, some dependencies are still stored in vendor/assets/javascript , and accessible as globals. The Webpack bundle declares those dependencies as external, and when serving the app, everything works great, as Rails serves the dependencies, which are then picked up by the bundle. Now I want to start testing the bundle using

JSDOM scraping on cloudfoundry doesn't work

青春壹個敷衍的年華 提交于 2019-12-24 12:49:27
问题 I'm using the jsdom node.js module for an app that does some web scraping to get some data it needs. This works perfectly fine when I run locally. When I push the application to cloudfoundry however, it crashes. The log is as follows: ====> /logs/stderr.log <==== /var/vcap/data/dea/apps/caretogethersandbox-0-8b20af9255bbf552d0f490cb60d0df55/app/node_modules/jsdom/lib/jsdom.js:171 features = JSON.parse(JSON.stringify(window.document.implementation._fea ^TypeError: Cannot read property

Jest secure cookies?

北城余情 提交于 2019-12-24 06:49:37
问题 My Jest tests are setup to mock my backend response when run on CI, but an environment variable allows them to run against the real backend locally. The problem is that we've now switched auth to use secure, http-only cookies. Is it possible to cause Jest to configure jsdom to respect cookies? I think jsdom's cookieJar config might do the trick, but can't figure out how to configure that via jest. 回答1: Seems like there's still no implementation for configuring jsdom for Jest https://github

Comparing the function output type in assertion

拈花ヽ惹草 提交于 2019-12-24 05:09:08
问题 I'm struggling with writing a test assertion using chai, mocha, and JS-DOM. I have a simple function like: function HtmlElement(el) { this.element = (el instanceof HTMLElement) ? el :document.createElement(el); } in the tests I have: it('should have addClass method', function () { const ul = (new HtmlElement('ul')); ul.element.should.be.equals('<ul></ul>'); // Outputs the actual UL }); but the error: AssertionError: expected <ul></ul> to equal '<ul></ul>' is the one I can't understand - what

How do I configure jsdom with jest

天涯浪子 提交于 2019-12-23 18:19:54
问题 I have installed jest and jsdom into my react project but I am having problems with importing a react component that uses the window.localStorage variable. I have added a setup file for jsdom that I believed would solve the problem. Here is my setup: jest config in package.json "jest": { "verbose": true, "testEnvironment": "jsdom", "testURL": "http://localhost:8080/Dashboard/index.html", "transform": { "^.+\\.js$": "<rootDir>/node_modules/babel-jest", "^.+\\.jsx$": "<rootDir>/node_modules

Load Google Maps API in jsdom

随声附和 提交于 2019-12-23 14:18:20
问题 I am trying to load the Google Maps API in jsdom. More specifically I am interested in getting the data from the getPanorama callback function. However, when I execute the following code I see 'Executed with no error', but I don't see any of the messages 'status ok' or 'status not ok'. var jsdom = require("jsdom"); var cafe = {lat: 51.47803167, lng: 0.141212256}; jsdom.env({ html: "<html><body></body></html>", scripts: ["https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"], done:

Get DOM element's actual width using jsdom

戏子无情 提交于 2019-12-21 11:30:37
问题 I wonder if I could get a DOM element's actual width and coordinates, as I can get using .clientWidth / .offsetWidth from within the browser. Does jsdom has browser rendering capabilities in order to get this data? If not, how can I get this within node.js server? Thanks! 回答1: JSDOM is strictly a DOM API emulation library. It does not attempt to actually render a document, which is necessary to compute element size and position. You may want to look at PhantomJS. It is a full WebKit renderer

Building contextify under Windows 7 x64 (for NodeJS jQuery)

做~自己de王妃 提交于 2019-12-20 17:47:46
问题 I try to get node-jquery working. contextify is one of the dependencies (required for jsdom ). contextify needs to be built somehow using Python. But this does not seem to work on Windows 7 x64. At least one my computer :) After some readings (#10, #12, #17) and trying some binaries provided by this fork and this one I can get it work ... I've got the same error from node-gyp configure or from node-gyp rebuild ( npm install jquery ) : info it worked if it ends with ok info downloading: http:/

Unmount / destroy Component in jsdom test

我怕爱的太早我们不能终老 提交于 2019-12-20 11:28:09
问题 Is there a way to unmount and garbage collect a React Component that was mounted using TestUtils.renderIntoDocument inside a jsdom test? I'm trying to test something that happens on componentWillUnmount and TestUtils.renderIntoDocument doesn't return any DOM node to call React. unmountComponentAtNode on. 回答1: No, but you can simply use ReactDOM.render manually: var container = document.createElement('div'); ReactDOM.render(<Component />, container); // ... ReactDOM.unmountComponentAtNode