node package manager
Stop wasting time. Easily manage code sharing in your team. Create a free org »

jest-environment-jsdom-latest

jest-environment-jsdom-latest

Jest environment to use the latest jsdom API and features

Install

$ npm install --save jest-environment-jsdom-latest

Usage

In index.spec.js or whatever:

/**
 * @jest-environment jsdom-latest
 */
 
test('use the latest jsdom features in this test file', () => {
  const element = document.createElement('div');
  expect(element).not.toBeNull();
});

Motivation

As of v10, jsdom has a new API and some cool new features. The downside is that now it requires a Node version >= 6.

As stated in the Jest documentation (here), the minimum supported Node version is v4.0.0.

This package helps you if you are running on Node >= 6 and want to use the latest JSDOM features. It will be deprecated when Jest drops Node 4 and Node 5 support.

The build script is as close as possible from the one of Facebook's Jest repo. More on Jest environments: http://facebook.github.io/jest/docs/configuration.html#testenvironment-string

License

MIT © Damien Seguin