-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for multiple reporters #3003
feat: add support for multiple reporters #3003
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along with customReporter
(if provided) could we also generate builtInReporter
? I think the issue also mentions that. In this case, we would need to pass in the path of default (builtin) reporter.
yes, it work for both |
lib/reporter/global-reporter.js
Outdated
loadFile(reporterFile) { | ||
const builtInReporterFileName = path.join(__dirname, 'reporters', reporterFile + '.js'); | ||
|
||
return Utils.fileExists(builtInReporterFileName).then((fileExists) => { | ||
if (!fileExists) { | ||
return this.loadCustomReporter(reporterFile); | ||
} | ||
|
||
return require(builtInReporterFileName); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gravityvi This takes care of both built-in reporter and custom reporter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it generates a single report with one --reporter
CLI value. Could we update it to generate the default builtInReporter
every time along with the reporter mentioned via CLI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, we can do that. I will update the PR
lib/reporter/global-reporter.js
Outdated
return require(builtInReporterFileName); | ||
}); | ||
if (!builtInReporter.includes(this.reporterFile)) { | ||
this.reporterFile = ['junit', this.reporterFile]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.reporterFile
when sending --reporter html.js,junit
from CLI comes out as a string 'html.js,junit'
, while an array is expected over here. We need to take care of that while getting cli args. Can you add a test for that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At max, this implementation can generate two reporters for a single test run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not meant to be used like that, we need to pass --reporter junit --reporter html.js
, but I will amend it to make use of the example you mentioned, as commonly people would prefer that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behaviour of using multiple reporters should be:
- pass the reporters via
nightwatch --reporter test_reporter.js --reporter junit
This is necessary because we have to keep the existing behaviour where you are using a custom reporter without using the junit reporter.
The test needs to reflect this so you need to write something like here: https://github.com/nightwatchjs/nightwatch/blob/main/test/src/runner/testRunnerSessionCreate.js#L133
runTests({
reporter: ['junit', 'other-reporter-file.js']
}, {
output_folder: true
});
}); | ||
}); | ||
|
||
it('test run tests with multiple reporters - html, junit, json', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is incomplete.
Thanks in advance for your contribution. Please follow the below steps in submitting a pull request, as it will help us with reviewing it quicker.
features/my-new-feature
orissue/123-my-bugfix
);fixes #2588