Skip to content

Commit

Permalink
Remove Karma flakiness by providing browser shims
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandrichardson authored and ljharb committed Sep 16, 2017
1 parent a30af83 commit 11d153e
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"author": "Leland Richardson <[email protected]>",
"license": "MIT",
"dependencies": {
"airbnb-browser-shims": "^3.0.0",
"chai": "^4.1.2",
"enzyme": "^3.3.0",
"enzyme-adapter-utils": "^1.5.0",
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/test/Adapter-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './_helpers/setup';
import React from 'react';
import { expect } from 'chai';
import jsdom from 'jsdom';
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/test/Debug-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './_helpers/setup';
import { expect } from 'chai';
import React from 'react';
import wrap from 'mocha-wrap';
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/test/RSTTraversal-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './_helpers/setup';
import React from 'react';
import sinon from 'sinon';
import { expect } from 'chai';
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* globals document */
import './_helpers/setup';
import React from 'react';
import PropTypes from 'prop-types';
import { expect } from 'chai';
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './_helpers/setup';
import React from 'react';
import PropTypes from 'prop-types';
import { expect } from 'chai';
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/test/Utils-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './_helpers/setup';
import React from 'react';
import { expect } from 'chai';
import wrap from 'mocha-wrap';
Expand Down
2 changes: 2 additions & 0 deletions packages/enzyme-test-suite/test/_helpers/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './setupShims';
import './setupAdapters';
14 changes: 14 additions & 0 deletions packages/enzyme-test-suite/test/_helpers/setupShims.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint no-undef: 0, global-require: 0 */
/**
* This file is needed only when karma runs the test suite. We can't guarantee
* what browser travis will actually run karma with, so we need to load in
* browser shims to make sure everything works that we expect. I'd love to
* put this somewhere else (ie, karma.conf.js), but I can't figure out how
* to tell karma to run a file before everything else. This is the next best
* thing I guess...
*/
const isBrowser = typeof window !== 'undefined' && Object.prototype.toString.call(window) === '[object Window]';

if (isBrowser) {
require('airbnb-browser-shims');
}
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/test/selector-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './_helpers/setup';
import React from 'react';
import { expect } from 'chai';
import {
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/test/staticRender-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './_helpers/setup';
import React from 'react';
import PropTypes from 'prop-types';
import { expect } from 'chai';
Expand Down

0 comments on commit 11d153e

Please sign in to comment.