Skip to content

Commit

Permalink
Disable HTML reporter in Cucumber. (nightwatchjs#4025)
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 authored Feb 16, 2024
1 parent fb4b0f2 commit ef98635
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
10 changes: 7 additions & 3 deletions lib/reporter/global-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ module.exports = class GlobalReporter {
this.suiteResults = [];
this.skippedSuites = 0;
this.uncaughtErr = null;
this.reporterFile = reporter;
this.reportFileName = reportFileName;

if (!Array.isArray(this.reporterFile) && typeof this.reporterFile == 'string') {
this.reporterFile = this.reporterFile.split(',');
this.reporterFile = [];
if (Array.isArray(reporter)) {
// Any subsequent changes in `this.reporterFile` shouldn't lead to changes in
// `argv.reporter` provided by the user, or `DefaultSettings.default_reporter`.
this.reporterFile = reporter.slice(0);
} else if (typeof reporter == 'string') {
this.reporterFile = reporter.split(',');
}
this.settings = settings;
this.summary = new Summary(settings);
Expand Down
20 changes: 20 additions & 0 deletions lib/runner/test-runners/cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const TestSuite = require('../../testsuite');
const {Logger, isString, isDefined} = require('../../utils');
const {NightwatchEventHub} = require('../eventHub.js');
const {getTestSourceForRerunFailed} = require('../rerunUtil.js');
const DefaultSettings = require('../../settings/defaults.js');

class CucumberSuite extends TestSuite {
static isSessionCreateError(err) {
Expand Down Expand Up @@ -252,6 +253,25 @@ class CucumberRunnner extends Runner {
return 'cucumber';
}

constructor(settings, argv, addtOpts) {
super(settings, argv, addtOpts);

// Disable HTML Reporter as it is not yet supported in Cucumber.
const reporterFile = this.globalReporter.reporterFile;
if (reporterFile && reporterFile.includes('html')) {
if (reporterFile.toString() !== DefaultSettings.default_reporter.toString()) {
// user has specifically asked for HTML report.
// eslint-disable-next-line no-console
console.warn(Logger.colors.yellow('HTML reporter is not supported with Cucumber runner.'));
}

const index = reporterFile.indexOf('html');
if (index > -1) {
reporterFile.splice(index, 1);
}
}
}

hasTestFailures(result) {
return result && result.success === false;
}
Expand Down
2 changes: 0 additions & 2 deletions lib/runner/test-runners/cucumber/_setup_cucumber_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Before(function({pickle, testCaseStartedId}) {
const webdriver = {};

process.env.CUCUMBER_TEST_CASE_STARTED_ID = testCaseStartedId;
// eslint-disable-next-line no-console
console.log('setup_cucumber_before', 'PID:', process.pid, 'testCaseStartedId:', testCaseStartedId);

if (this.parameters['webdriver-host']) {
webdriver.host = this.parameters['webdriver-host'];
Expand Down

0 comments on commit ef98635

Please sign in to comment.