Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
features.forEach(function (feature) {
// create new feature
const suite = builder
.testSuite()
.name(options.suiteNamePrefix + feature.name)
// quit here if feature is empty
if (!feature.elements) { return }
// loop over scenarios
feature.elements.forEach(function (scenario) {
let result = false
const messages = []
// loop over steps
scenario.steps.forEach(function (step) {
// quit if steps are empty
if (step.result) {
// on failure
if (step.result.status === 'failed') {
result = 'failure'
module.exports = function (result, outFile) {
var suite = junitReportBuilder.testSuite()
.name(result.url)
.timestamp(new Date().getTime())
.time(new Date().toGMTString());
var packageName = result.url;
result.violations.forEach(function (ruleResult) {
ruleResult.nodes.forEach(function (violation) {
var failure = ruleResult.help + ' (' + ruleResult.helpUrl + ')\n';
var stacktrace = 'Target: ' + violation.target + '\n\n' +
'HTML: ' + violation.html + '\n\n' +
'Summary:\n';
if (violation.any.length) {
stacktrace += 'Fix any of the following:\n';
return lighthouseRunner.run().then(() => {
sandbox.assert.calledWith(
reportBuilder.testSuite().testCase().failure,
'Error on http://www.bbc.co.uk/path/2\n' +
'Image alt help text\n\n' +
'Failing elements:\n' +
'button > svg[role="img"] - <svg class="cta__icon cta__icon--left" role="img">'
);
});
});</svg>
return lighthouseRunner.run().then(() => {
sandbox.assert.calledTwice(reportBuilder.testSuite);
sandbox.assert.calledWith(reportBuilder.testSuite().name, 'base.url./path/1');
sandbox.assert.calledWith(reportBuilder.testSuite().name, 'base.url./path/2');
});
});
return lighthouseRunner.run().then(() => {
sandbox.assert.calledTwice(reportBuilder.testSuite);
sandbox.assert.calledWith(reportBuilder.testSuite().time, 6000);
});
});
.then((results) => {
const suiteName = url.replace(/.*?:\/\//g, '').replace('\/', './');
const suite = reportBuilder.testSuite();
suite.name(suiteName);
const { audits, timing: { total: suiteDuration } } = results;
suite.time(suiteDuration);
const auditKeys = Object.keys(audits).filter((auditKey) => !audits[auditKey].manual);
const testCaseTime = (suiteDuration / auditKeys.length);
auditKeys.forEach((auditKey) => {
const { score, manual, description, helpText, details = {}, extendedInfo = {} } = audits[auditKey];
const testCase = suite.testCase();
testCase.className(suiteName);
testCase.name(description);
testCase.time(testCaseTime);
JUnitReport.prototype.pageChecked = function(page, validationResult) {
var suiteName = page.url;
suiteName = suiteName.replace(/.*?:\/\//g, "").replace('\/', './');
var suite = builder.testSuite().name(suiteName)
validationResult.results.forEach(function(standardResult) {
var standard = standardResult.standard
var testName = standard.section.title + ': ' + standard.name
var docsUrl = standard.section.documentationUrl
var testcase = suite.testCase().className(suiteName).name(testName)
if (standardResult.errors.length > 0) {
var errors = standardResult.errors.map(prettyErrorOutput)
testcase.failure('Error on ' + page.url + errors.join('') + '\nMore info at ' + docsUrl)
}
})
}
JUnitReport.prototype.pageChecked = function (page, validationResult) {
const suiteName = page.url.replace(/.*?:\/\//g, '').replace('\/', './');
const suite = builder.testSuite();
suite.name(suiteName);
validationResult.results.forEach((standardResult) => {
const standard = standardResult.standard;
const testName = standard.section.title + ': ' + standard.name;
const docsUrl = standard.section.documentationUrl;
const testCase = suite.testCase();
testCase.className(suiteName);
testCase.name(testName);
if (standardResult.errors && standardResult.errors.length) {
const errors = standardResult.errors.map(prettyErrorOutput);
testCase.failure('Error on ' + page.url + errors.join('') + '\nMore info at ' + docsUrl);
}
});
};
function writeJunitReport (config, reporter) {
logger.log('Writing jUnit Report');
var builder = require('junit-report-builder');
var suite = builder.testSuite()
.name(reporter.testSuite);
for (var i in reporter.tests) {
if (!reporter.tests.hasOwnProperty(i)) {
continue;
}
var test = reporter.tests[i];
var testCase = suite.testCase()
.className(test.pair.selector)
.name(' ›› ' + test.pair.label);
if (!test.passed()) {
var error = 'Design deviation ›› ' + test.pair.label + ' (' + test.pair.selector + ') component';
testCase.failure(error);
testCase.error(error);