-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.istanbul-mocha.config.js
41 lines (30 loc) · 1.38 KB
/
.istanbul-mocha.config.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
'use strict';
// Istanbul can not run coverage without a DOM.
// I don't know how to configure Istanbul to run code before and after Mocha tests, so for now, this is what
// I've come up with. This is not an ideal solution, since we do not get cleaned up after Istanbul has completed.
import jsdomify from 'jsdomify'
import requireUncached from 'require-uncached'
jsdomify.create('<!doctype html><html><body><div id="mount"></div></body></html>');
requireUncached( 'material-design-lite/material'); // See: https://github.com/mochajs/mocha/issues/1722
global.componentHandler = window.componentHandler;
/*
// jsdomify does not understand Element.insertAdjacentHTML, throws error
const mount = document.querySelector('#mount')
mount.insertAdjacentHTML('beforeend', '<p>FOO</p>')
console.log(mount.innerHTML)
*/
/*
// Testcase to verify that Element.insertAdjacentHTML works with jsdom
import jsdom from 'jsdom'
// setup the simplest document possible
const doc = jsdom.jsdom('<!doctype html><html><body><div id="mount"></div></body></html>')
// get the window object out of the document
const win = doc.defaultView
// set globals for mocha that make access to document and window feel
// natural in the test environment
global.document = doc
global.window = win
const mount = document.querySelector('#mount');
mount.insertAdjacentHTML('beforeend', '<p>FOO</p>')
console.log(mount.innerHTML)
*/