-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reporting - Output to file #90
Comments
There are actually two separate issues here:
|
I created a separate issue regarding the multiple formatters. |
Julien is there any news on when we would be able to specify an HTML output file? |
+1 |
1 similar comment
+1 |
HI I have been manually copying and pasting the content of the JSON results to the cucumber.json file in the data directory of cucumber-json2report-master, which does allow me to get some nice results of the run, but it would be great if cucumber.js could place the file in that directory, thus eliminating the manual step. I don't really want to hack the version or create a fork. Suggestions? |
Any update on this? |
@letshaveyer this sounds like a useful feature to you. Why don't you send a pull request? |
Until this is working you can modify json_formatter.js. This is hack but much easier that copying an pasting every time. We also are adding a time stamp to the filename. Change the formatterIo object to also write to a file var formatterIo = { |
This is a simple thing to do with simple pipe redirects in unix and bash
+1 to close |
We can't pipe it. We're using protractor's config file to set cucumberjs CucumberOpts: { We have a bat file that uses node to start protractor. Brad
|
Interesting @brad8118 this seems like it would be a feature of protractor and not cucumber. protractor is invoking cucumber and what it does with the output is the responsibility of protractor and not cucumber. Those are just my initial thoughts, open to ideas tho. I am just trying to prevent feature creep of the cucumber lib. |
@brad8118 I am using protractor. I dosn't really want to muddle source code. Is there a way that I can add a hook or support file to do that? var formatterIo = {
write: function(string){
self.log(string);
fs.writeFileSync('path\test_results.json', string); // added
}
}; |
@samccone protractor use native reporting depends which framework that you are using. If you are using Jasmine, it will use reporting in Jasmine. If you are using cucumber framework, it will use reporting in cucumber.js, which currently has no way to output a file. |
@jlin412, I don't know how to pass / get the json that's being generated without changing cucumber.js.
Looks like this is already done in another fork. nicolassenechal/cucumber-js@b337b18 |
@jlin412 when you cute and paste the json. What are you doing with it? Are you converting it into html? |
@brad8118 I use redirection to send json output to a file from protractor and then I have grunt task function to filter out json format using regex match: grunt.registerTask('jsonOutput', function () {
var testOutput = grunt.file.read('test/e2e/tmp/cucumberOutput.json');
var json = testOutput.match(/(\[\s+\{[\s\S]*\}\s+\]\s+\}\s+\]\s+\}\s+\])/)[1];
grunt.file.write('test/e2e/output/cucumberReport.json', json);
}); Then I use cucumber sandwich to convert to html (A java project). I made slight modification to cucumber sandwich code base so I can call it on demand rather than depending on the file event listener. |
Hi Guys, just trying to get my head around when this will be committed back to the cucumber-js Master? I need this functionality now, but I'm wary of relying on a forked branch. Could you give me an idea of when it will be available in cucumber-js master and just a quick idea of whether it's wise to rely on one of the forked branches in the meantime? Thanks, Fraser. |
+1 -- I know I'm not alone in going through some crazy contortions to use cucumber with protractor when a flag to write to file would be sooo helpful. I don't understand why writing to a file is considered feature creep. Is cucumber only intended to allow developers to visually inspect the quality of their work? Are we not supposed to use cucumber within the scope of a larger test environment? This can't be so... |
Hi, Anyone can help me, i've not found how to configure properly json output into file. Thanks in advance |
There is a way to select a directory to json output from protractor from 1.5.0 though I haven't used it. module.exports = function JsonOutputHook() {
var Cucumber = require('cucumber');
var JsonFormatter = Cucumber.Listener.JsonFormatter();
var fs = require('fs');
JsonFormatter.log = function (json) {
fs.writeFile('test/e2e/output/cucumberReport.json', json, function (err) {
if (err) throw err;
console.log('json file location: test/e2e/output/cucumberReport.json');
});
};
this.registerListener(JsonFormatter);
}; |
I've not seen the Cédric 2015-01-02 18:34 GMT+01:00 Jason Lin [email protected]:
|
Switch back to pretty print in the Protractor cucumberOpts and add a JSON output listener as per [cucumber/cucumber-js#90 (comment)]
+1 |
So could we please get an update on when this will get committed to master? I'm currently using cucumberjs minus protractor (or any other selenium style web test framework) so I need cucumberjs to produce a formatted report. |
Any update on this? This has caused us enough issues to think about patching this module or looking at parallel-cucumber (which handles this case). cucumberjs -> webdriverio |
+1 |
I follow this description to save cucumberjs json format.
It's work |
if anyone is missing happy hour due to cucumber js reports, we are using cucumber-html-reports
support.registerHandler('AfterFeatures', () => {
///* creates report
var options = {
theme: 'bootstrap',
jsonFile: 'cucumberReports/report.json',
output: 'cucumberReports/report.html',
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
"App Version":"0.3.2",
"Test Environment": "POC",
//"Browser": "Chrome 54.0.2840.98",
//"Platform": "Windows 10",
//"Parallel": "Scenarios",
//"Executed": "Remote"
}
};
reporter.generate(options);
}); update your protractor.conf.cucumberOpts |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
It is currently not possible to specify an "output" file as a CLI argument for saving reports. The JSON formatter seems to write directly to STDOUT, which can be a problem when debugging (using console.log) or if the program fails, producing invalid JSON.
It would be desirable if this worked like cucumber in ruby, allowing multiple formats saved out to separate output files.
The text was updated successfully, but these errors were encountered: