You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Luke Childs fb47e69df7 3.1.2 8 years ago
src Strict mode for Noce.js v4 v5 8 years ago
test Test jsdom config is passed through 8 years ago
.gitignore Extract window function from browser-env 8 years ago
.travis.yml Extract window function from browser-env 8 years ago
LICENSE Extract window function from browser-env 8 years ago
README.md Quote string response in readme 8 years ago
package.json 3.1.2 8 years ago

README.md

window

Exports a jsdom window object.

Build Status Coverage Status npm

Exports a jsdom window object. This is useful for enabling browser modules to run in Node.js or testing browser modules in any Node.js test framework.

Install

npm install --save window

Or if you're just using for testing you'll probably want:

npm install --save-dev window

Usage

const Window = require('window');

const window = new Window();

const div = window.document.createElement('div');
// HTMLDivElement

div instanceof window.HTMLElement
// true

Because window is just a normal JavaScript object it can be used more efficiently with object destructuring.

const { document } = new Window();

document.body.innerHTML = '<div class="foo">Hi!</div>';
document.body.querySelector('.foo').textContent;
// "Hi!"

License

MIT © Luke Childs