-
Notifications
You must be signed in to change notification settings - Fork 1
/
browser.js
56 lines (50 loc) · 1.99 KB
/
browser.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import _sinon from 'sinon';
import addLegacyMethodsToSinon from './lib/addLegacyMethodsToSinon.js';
import _testCase from './lib/testCase.js';
import bochaUiFactory from './lib/bochaUiFactory.js';
import htmlReporter from './lib/reporters/htmlReporter.cjs';
addLegacyMethodsToSinon(_sinon);
export const sinon = _sinon;
export const stub = sinon.stub;
export const spy = sinon.spy;
export { default as assert } from './lib/dom/assert.js';
export { default as refute } from './lib/dom/refute.js';
export { default as waitStub } from './lib/waitStub.js';
export { default as timeout } from './lib/timeoutPromise.js';
export {
clickAndTick as click,
setValueAndTick as setValue,
focusAndTick as focus,
blurAndTick as blur,
keydownAndTick as keydown,
keydownAndTickWithModifiers as keydownWithModifiers,
mouseupAndTick as mouseup,
pasteIntoInputAndTick as pasteIntoInput,
htmlToElement,
detachElements
} from './lib/dom/dom.js';
export { default as fakeClock } from './lib/fakeClock.js';
export { default as defaults } from 'lodash.defaults';
export { default as defaultsDeep } from 'lodash.defaultsdeep';
export { default as localToUtc } from './lib/localToUtc.js';
export { default as utcToLocal } from './lib/utcToLocal.js';
export { default as catchError } from './lib/catchError.js';
export { default as catchErrorAsync } from './lib/catchErrorAsync.js';
export const testCase = testCaseWrapper;
export const $ = (selector => document.querySelector(selector));
export const $$ = (selector => document.querySelectorAll(selector));
let mocha = window.mocha;
if (!mocha || !mocha.suite || !mocha.suite.emit) {
throw new Error('Mocha for the browser must be loaded before requiring Bocha.');
}
window.__sinon = sinon;
let Mocha = window.Mocha;
Mocha.interfaces['bocha'] = bochaUiFactory(Mocha);
mocha.setup({
ui: 'bocha',
reporter: htmlReporter
});
function testCaseWrapper(name, obj) {
let suite = _testCase(name, obj);
mocha.suite.emit('require', suite, null, mocha);
}