Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mocha-simple-html-reporter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha-simple-html-reporter - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

CHANGELOG.md

79

index.js
'use strict';
const fs = require('fs');
const mocha = require('mocha');
const utils = mocha.utils;
const templates = require('./lib/templates');
const findStylesheet = require('./lib/find-stylesheet');
module.exports = function (runner, options) {
mocha.reporters.Base.call(this, runner);
const reporterOpts = options.reporterOptions || {};
const stats = this.stats;
const cssPath = findStylesheet();
let result = '';
runner.on('end', () => {
const output = reporterOpts.output;
const head = templates.head({ css: fs.readFileSync(cssPath, 'utf-8') });
const body = templates.body({
passes: stats.passes,
failures: stats.failures,
duration: stats.end - stats.start,
report: result
});
const html = `<html>${head}${body}</html>`;
if (!output) {
return console.log(html);
}
try {
fs.writeFileSync(output, html);
console.log(`The report is written in "${output}" file.`);
} catch (err) {
console.error(err);
}
});
runner.on('suite', suite => {
if (suite.root) { return; }
const title = utils.escape(suite.title);
result += '<li class="suite">';
result += `<h1>${title}</h1>`;
result += '<ul>';
});
runner.on('suite end', suite => {
if (suite.root) { return; }
result += '</ul>';
result += '</li>';
});
runner.on('pass', test => {
const title = utils.escape(test.title);
const code = utils.escape(utils.clean(test.body));
result += `<li class="test pass ${test.speed}">`;
result += `<h2>${title}<span class="duration">${test.duration}ms</span></h2>`;
result += `<pre><code>${code}</code></pre>`;
result += '</li>';
});
runner.on('fail', test => {
const title = utils.escape(test.title);
const stacktrace = utils.escape(test.err.stack);
result += '<li class="test fail">';
result += `<h2>${title}</h2>`;
result += `<pre class="error">${stacktrace}</pre>`;
result += '</li>';
});
};
module.exports = require('./lib');

@@ -8,4 +8,6 @@ 'use strict';

const mochaDirname = path.dirname(mochaMainFilename);
const nativeStylesheet = path.join(mochaDirname, 'mocha.css');
const htmlReportStylesheet = path.join(__dirname, 'assets', 'html-report.css');
return path.join(mochaDirname, 'mocha.css');
return [nativeStylesheet, htmlReportStylesheet];
};
{
"name": "mocha-simple-html-reporter",
"version": "1.0.1",
"version": "1.1.0",
"description": "HTML reporter for Mocha",

@@ -23,15 +23,16 @@ "license": "MIT",

"dependencies": {
"pretty-ms": "2.1.0"
"pretty-ms": "3.0.1"
},
"devDependencies": {
"deasync": "^0.1.7",
"eslint": "^3.0.0",
"eslint-config-pedant": "^0.8.0",
"mocha": "^3.0.2",
"should": "^11.1.0"
"eslint": "^4.9.0",
"eslint-config-pedant": "^0.10.0",
"mocha": "^4.0.0",
"should": "^13.1.2",
"unexpected": "^10.36.0"
},
"scripts": {
"test": "eslint .",
"example": "mocha examples/test.js --reporter=$PWD --opts examples/mocha.opts"
"example": "UNEXPECTED_FULL_TRACE=true mocha examples/test.js --reporter=$PWD --opts examples/mocha.opts --no-colors"
}
}

@@ -12,6 +12,6 @@ mocha-simple-html-reporter

[travis]: https://travis-ci.org/blond/mocha-simple-html-reporter
[test-img]: https://img.shields.io/travis/blond/mocha-simple-html-reporter.svg?label=tests
[test-img]: https://img.shields.io/travis/blond/mocha-simple-html-reporter/master.svg?label=tests
[david]: https://david-dm.org/blond/mocha-simple-html-reporter
[david-img]: http://img.shields.io/david/blond/mocha-simple-html-reporter.svg?style=flat
[david-img]: https://img.shields.io/david/blond/mocha-simple-html-reporter/master.svg?style=flat

@@ -23,3 +23,3 @@ This is a custom reporter for use with the Javascript testing framework, [mocha](http://mochajs.org/). It generates a HTML/CSS report that helps visualize your test suites.

![Sample Report](https://cloud.githubusercontent.com/assets/2225579/18583359/d5f0c0b6-7c12-11e6-8c73-d606497a4878.png)
![Sample Report](./report.gif)

@@ -64,2 +64,3 @@ Install

* It not able report about failures only. If your project has many tests, it is difficult to find the error among thousands of passed tests.
* It able to return HTML-report only in console. There is no way to write to a file if your tests writing something to `stdout`.

@@ -66,0 +67,0 @@ * It requires concatenating result with `head.html` and `tail.html` to build report with styles and scripts.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc