Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Karma flakiness by providing browser shims #1119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ matrix:
- node_js: "6"
env: KARMA=true REACT=16
allow_failures:
- node_js: "6"
env: KARMA=true REACT=0.13
- node_js: "6"
env: KARMA=true REACT=0.14
- node_js: "6"
env: KARMA=true REACT=15.4
- node_js: "6"
env: KARMA=true REACT=15
- node_js: "6"
env: KARMA=true REACT=16
env:
- REACT=16
- REACT=16.2
Expand Down
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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually both safe to require in node, and recommended to do so.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. doing so caused many issues. perhaps it's related to jsdom?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah true, that makes sense.

}
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