Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
},
});
failedTests += totalFailed;
}
// Merge all json reports into one single json report
const jsonReport = await merge({reportDir: mochawesomeReportDir});
// Generate short summary to easily pickup via hook
const summary = generateShortSummary(jsonReport);
writeJsonToFile(summary, 'summary.json', mochawesomeReportDir);
// Generate the html report file
await generator.create(jsonReport, {reportDir: mochawesomeReportDir});
// eslint-disable-next-line
process.exit(failedTests); // exit with the number of failed tests
}
async function runTests() {
await fse.remove('mochawesome-report') // remove the report folder
const { totalFailed } = await cypress.run({
browser: "chrome",
reporter: "mochawesome",
reporterOptions: {
overwrite: false,
html: false,
json: true,
quiet: true
},
}); // get the number of failed tests
const jsonReport = await merge(); // generate JSON report
await generator.create(jsonReport);
process.exit(totalFailed); // exit with the number of failed tests
}
'use strict';
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var marge = require('mochawesome-report-generator');
// Grab shared base config from mochawesome-report-generator
var baseConfig = (0, _assign2.default)(marge.getBaseConfig(), {
reportFilename: 'mochawesome',
saveJson: true
});
var boolOpts = ['inlineAssets', 'autoOpen', 'enableCharts', 'enableCode', 'overwrite', 'quiet', 'dev'];
function _getOption(optToGet, options, isBool) {
var envVar = 'MOCHAWESOME_' + optToGet.toUpperCase();
// Order of precedence
// 1. Config option
// 2. Environment variable
// 3. Base config
if (options && typeof options[optToGet] !== 'undefined') {
return isBool && typeof options[optToGet] === 'string' ? options[optToGet] === 'true' : options[optToGet];
}
if (typeof process.env[envVar] !== 'undefined') {
const rootSuite = mapSuites(this.runner.suite, totalTestsRegistered, this.config);
const obj = {
stats: this.stats,
results: [ rootSuite ],
meta: {
mocha: {
version: mochaPkg.version
},
mochawesome: {
options: this.config,
version: pkg.version
},
marge: {
options: options.reporterOptions,
version: margePkg.version
}
}
};
obj.stats.testsRegistered = totalTestsRegistered.total;
const { passes, failures, pending, tests, testsRegistered } = obj.stats;
const passPercentage = (passes / (testsRegistered - pending)) * 100;
const pendingPercentage = (pending / testsRegistered) * 100;
obj.stats.passPercent = passPercentage;
obj.stats.pendingPercent = pendingPercentage;
obj.stats.other = (passes + failures + pending) - tests; // Failed hooks
obj.stats.hasOther = obj.stats.other > 0;
obj.stats.skipped = testsRegistered - tests;
obj.stats.hasSkipped = obj.stats.skipped > 0;
function done(output, config, failures, exit) {
return marge.create(output, config).then(function (_ref) {
var _ref2 = (0, _slicedToArray3.default)(_ref, 2),
htmlFile = _ref2[0],
jsonFile = _ref2[1];
log('Report JSON saved to ' + jsonFile, null, config);
log('Report HTML saved to ' + htmlFile, null, config);
}).catch(function (err) {
log(err, 'error', config);
}).then(function () {
exit && exit(failures);
});
}
function done(output, options, config, failures, exit) {
return marge.create(output, options)
.then(([ htmlFile, jsonFile ]) => {
if (!htmlFile && !jsonFile) {
log('No files were generated', 'warn', config);
} else {
jsonFile && log(`Report JSON saved to ${jsonFile}`, null, config);
htmlFile && log(`Report HTML saved to ${htmlFile}`, null, config);
}
})
.catch(err => {
log(err, 'error', config);
})
.then(() => {
exit && exit(failures > 0 ? 1 : 0);
});
}
protractorConfig.afterLaunch = async function (...args) {
const reports = await existsAsync(reportDirOptions.reportDir);
if (reports) {
const report = await merge(reportDirOptions);
await marge.create(report, { autoOpen, ...reportDirOptions });
await rimrafAsync(path.resolve(reportDirOptions.reportDir, './*.json'));
}
if (afterLaunch) {
afterLaunch.call(this, ...args);
}
};
return merge(options).then((report: any) =>
marge.create(report, options)
);