| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/nami/node_modules/mocha-multi/ |
Upload File : |
const Mocha = require('mocha');
const should = require('should');
const fs = require('fs');
const debug = require('debug')('mocha:verify:multi');
const async = require('async');
const chalk = require('chalk');
const reporters = [
'dot', 'doc', 'spec', 'json', 'progress',
'list', 'tap', 'landing', 'xunit', 'min',
'json-stream', 'markdown', 'nyan',
];
const now = new Date();
function tempName(reporter) {
return `/tmp/mocha-multi.${reporter}.${+now}`;
}
const reportersWithOptions = []
.concat(reporters.map((reporter) => {
const outFilename = tempName(`${reporter}-stdout`);
const options = {};
options[reporter] = {
stdout: outFilename,
};
return {
testName: `${reporter} (with options.stdout)`,
outFilename,
options,
};
}))
.concat(reporters.map((reporter) => {
const outFilename = tempName(`${reporter}-str`);
const options = {};
options[reporter] = outFilename;
return {
testName: `${reporter} (with options as string)`,
outFilename,
options,
};
}));
should(process.env.multi).not.be.ok;
process.setMaxListeners(reportersWithOptions.length);
async.eachSeries(reportersWithOptions, (reporter, next) => {
debug('reporter %s', reporter.testName);
debug('reporterOptions %j', reporter.options);
const mocha = new Mocha({
ui: 'bdd',
reporter: 'mocha-multi',
reporterOptions: reporter.options,
});
mocha.addFile('test/dummy-spec.js');
mocha.run(() => {
debug('done running %j', reporter.testName);
process.nextTick(next);
});
}, () => {
reportersWithOptions.forEach((reporter) => {
fs.statSync.bind(fs, reporter.outFilename).should.not.throw();
fs.unlinkSync(reporter.outFilename);
// eslint-disable-next-line no-console
console.log(chalk.green('%s OK'), reporter.testName);
});
});