MCPcopy Create free account
hub / github.com/deployd/deployd / HTML

Function HTML

test-app/public/mocha.js:2530–2718  ·  view source on GitHub ↗

* Initialize a new `HTML` reporter. * * @public * @class * @memberof Mocha.reporters * @extends Mocha.reporters.Base * @api public * @param {Runner} runner

(runner)

Source from the content-addressed store, hash-verified

2528 * @param {Runner} runner
2529 */
2530 function HTML(runner) {
2531 Base.call(this, runner);
2532
2533 var self = this;
2534 var stats = this.stats;
2535 var stat = fragment(statsTemplate);
2536 var items = stat.getElementsByTagName('li');
2537 var passes = items[1].getElementsByTagName('em')[0];
2538 var passesLink = items[1].getElementsByTagName('a')[0];
2539 var failures = items[2].getElementsByTagName('em')[0];
2540 var failuresLink = items[2].getElementsByTagName('a')[0];
2541 var duration = items[3].getElementsByTagName('em')[0];
2542 var canvas = stat.getElementsByTagName('canvas')[0];
2543 var report = fragment('<ul id="mocha-report"></ul>');
2544 var stack = [report];
2545 var progress;
2546 var ctx;
2547 var root = document.getElementById('mocha');
2548
2549 if (canvas.getContext) {
2550 var ratio = window.devicePixelRatio || 1;
2551 canvas.style.width = canvas.width;
2552 canvas.style.height = canvas.height;
2553 canvas.width *= ratio;
2554 canvas.height *= ratio;
2555 ctx = canvas.getContext('2d');
2556 ctx.scale(ratio, ratio);
2557 progress = new Progress();
2558 }
2559
2560 if (!root) {
2561 return error('#mocha div missing, add it to your document');
2562 }
2563
2564 // pass toggle
2565 on(passesLink, 'click', function(evt) {
2566 evt.preventDefault();
2567 unhide();
2568 var name = /pass/.test(report.className) ? '' : ' pass';
2569 report.className = report.className.replace(/fail|pass/g, '') + name;
2570 if (report.className.trim()) {
2571 hideSuitesWithout('test pass');
2572 }
2573 });
2574
2575 // failure toggle
2576 on(failuresLink, 'click', function(evt) {
2577 evt.preventDefault();
2578 unhide();
2579 var name = /fail/.test(report.className) ? '' : ' fail';
2580 report.className = report.className.replace(/fail|pass/g, '') + name;
2581 if (report.className.trim()) {
2582 hideSuitesWithout('test fail');
2583 }
2584 });
2585
2586 root.appendChild(stat);
2587 root.appendChild(report);

Callers

nothing calls this directly

Calls 8

fragmentFunction · 0.85
errorFunction · 0.85
onFunction · 0.85
unhideFunction · 0.85
hideSuitesWithoutFunction · 0.85
updateStatsFunction · 0.85
appendToStackFunction · 0.85
escapeFunction · 0.70

Tested by

no test coverage detected