Skip to content

Commit

Permalink
* add global.document to test enviorment for setState tests
Browse files Browse the repository at this point in the history
This curcumvents a bug ir React. You can see a manifestation of it [here](facebook/react#4019).

This existence of a `document` is required by React, when using `setState`. While `shallowRenderer` is inteded for use without a document, all tests that use `setState` will fail with a `documentis not defined`reference error.

Fortunately, React doesn't need anything more than the existance of the global. So, we can define it in our test environment.

This is where a more robust environment could be setup, using [jsdom](https://www.npmjs.com/package/jsdom) if needed.
  • Loading branch information
chantastic committed Sep 2, 2015
1 parent 9bc01a0 commit 3361126
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--require test/utils/document.js
--compilers js:babel/register
1 change: 1 addition & 0 deletions test/utils/document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global.document = {};

0 comments on commit 3361126

Please sign in to comment.