forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render-target.js
42 lines (32 loc) · 1004 Bytes
/
render-target.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
import $ from 'cash-dom'
function appendTargetIfNotExists (id, tag = 'div', parent = document.body) {
let node = document.getElementById(id)
if (!node) {
node = document.createElement(tag)
node.setAttribute('id', id)
parent.appendChild(node)
}
node.innerHTML = ''
return node
}
/** Renders the app's target structure **
* The mocha div is the container for the reporter <div id="mocha" />
* The Evergreen AUT will be re-created between runs
* The Root container div will be replaced when mount is called
*/
export function renderTargets () {
const containerEl = appendTargetIfNotExists('evergreen-aut')
appendTargetIfNotExists('root', 'div', containerEl)
}
export function renderMochaTarget () {
const $mocha = $('#mocha')
const $testRun = $('#test-run')
if ($mocha.length) $mocha[0].innerHTML = ''
if ($testRun.length) {
return
}
$('#plugins').append(`<section id="test-run">
<h2>Test Run</h2>
<div id="mocha"></div>
</section>`)
}