-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathunit-testing-react-setup.js
More file actions
35 lines (31 loc) · 1.32 KB
/
unit-testing-react-setup.js
File metadata and controls
35 lines (31 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
document.addEventListener('DOMContentLoaded', function() {
'use strict';
var callCount = 0;
var interval = window.setInterval(function() {
// Prevent fatal development errors from calling timeout over and over.
// Otherwise the browser can hang from a large number of quick calls to `window.setInterval()`.
callCount++;
if (callCount > 20) {
window.clearInterval(interval);
var error = 'Unexpected error loading scripts, check DevTools';
var root = document.getElementById('root');
root.textContent = error;
root.className = 'error';
root.style.display = '';
throw new Error(error);
}
// Wait until [jsxLoader.js] has finished loading all files
if (jsxLoader.hasPendingScripts()) {
return;
}
// Show compiler options that were used
window.clearInterval(interval);
var library = (window.preact !== undefined ? ' (Preact)' : '');
document.querySelector('#compile-type strong').textContent = (jsxLoader.isSupportedBrowser ? 'jsxLoader' : 'Babel') + library;
if (jsxLoader.needsPolyfill) {
document.getElementById('polyfill-status').style.display = '';
}
// Run Tests
mocha.run();
}, 100);
});