Skip to content

Commit

Permalink
MissingObserver polyfill for jest environment
Browse files Browse the repository at this point in the history
References by noVNC (@novnc/nvnc/core/util/events.js).
Workaround just for the `jest` testing - the MutationObserver
is available in browsers.

Use of `browser` jest configuration option does not help.
  • Loading branch information
mareklibra committed Mar 29, 2018
1 parent 421cfc4 commit 9cbbe32
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"istanbul-reports": "1.1.4",
"jest": "^22.4.2",
"jest-cli": "^22.4.2",
"mutation-observer": "^1.0.3",
"node-sass": "^4.7.2",
"prettier": "^1.9.2",
"prettier-eslint": "^8.8.1",
Expand Down
6 changes: 6 additions & 0 deletions src/test.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ import 'raf/polyfill';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

const MutationObserverPolyfill = require('mutation-observer');

// referenced from '@novnc/nvnc/core/util/events.js'
// The MutationObserver is available in supported browsers, this is workaround for "jest"
global.MutationObserver = global.MutationObserver || MutationObserverPolyfill;

configure({ adapter: new Adapter() });

0 comments on commit 9cbbe32

Please sign in to comment.