Skip to content

Commit 11d153e

Browse files
lelandrichardsonljharb
authored andcommitted
Remove Karma flakiness by providing browser shims
1 parent a30af83 commit 11d153e

11 files changed

+25
-0
lines changed

packages/enzyme-test-suite/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"author": "Leland Richardson <[email protected]>",
3030
"license": "MIT",
3131
"dependencies": {
32+
"airbnb-browser-shims": "^3.0.0",
3233
"chai": "^4.1.2",
3334
"enzyme": "^3.3.0",
3435
"enzyme-adapter-utils": "^1.5.0",

packages/enzyme-test-suite/test/Adapter-spec.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './_helpers/setup';
12
import React from 'react';
23
import { expect } from 'chai';
34
import jsdom from 'jsdom';

packages/enzyme-test-suite/test/Debug-spec.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './_helpers/setup';
12
import { expect } from 'chai';
23
import React from 'react';
34
import wrap from 'mocha-wrap';

packages/enzyme-test-suite/test/RSTTraversal-spec.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './_helpers/setup';
12
import React from 'react';
23
import sinon from 'sinon';
34
import { expect } from 'chai';

packages/enzyme-test-suite/test/ReactWrapper-spec.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* globals document */
2+
import './_helpers/setup';
23
import React from 'react';
34
import PropTypes from 'prop-types';
45
import { expect } from 'chai';

packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './_helpers/setup';
12
import React from 'react';
23
import PropTypes from 'prop-types';
34
import { expect } from 'chai';

packages/enzyme-test-suite/test/Utils-spec.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './_helpers/setup';
12
import React from 'react';
23
import { expect } from 'chai';
34
import wrap from 'mocha-wrap';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import './setupShims';
2+
import './setupAdapters';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* eslint no-undef: 0, global-require: 0 */
2+
/**
3+
* This file is needed only when karma runs the test suite. We can't guarantee
4+
* what browser travis will actually run karma with, so we need to load in
5+
* browser shims to make sure everything works that we expect. I'd love to
6+
* put this somewhere else (ie, karma.conf.js), but I can't figure out how
7+
* to tell karma to run a file before everything else. This is the next best
8+
* thing I guess...
9+
*/
10+
const isBrowser = typeof window !== 'undefined' && Object.prototype.toString.call(window) === '[object Window]';
11+
12+
if (isBrowser) {
13+
require('airbnb-browser-shims');
14+
}

packages/enzyme-test-suite/test/selector-spec.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './_helpers/setup';
12
import React from 'react';
23
import { expect } from 'chai';
34
import {

packages/enzyme-test-suite/test/staticRender-spec.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './_helpers/setup';
12
import React from 'react';
23
import PropTypes from 'prop-types';
34
import { expect } from 'chai';

0 commit comments

Comments
 (0)