Configurations for using a custom JSON Formatter
See original GitHub issueCurrent behavior
JSON Formatter is required to be installed by anyone who wishes to use the reporting functionality. This adds an additional installation step / dependency to any machine running tests. It also seems to tightly couple JSON generation with the preprocessor.
Desired behavior
A way to add a custom JSON formatter other than the required Standalone executable one.
This could be a configuration option that would allow the user to only generate the .ndjson file before running their own formatting process once the preprocessor has finished?
After reading the docs I did try to achieve this with json.args: [“custom-formatter.js”] but couldn’t find supporting documentation for that option. I also ran into the ENOENT issue from the FAQ (where the Standalone Cucumber JSON Formatter is being searched for, even with the formatter variable set in package.json).
I used many variations of the config “json.enabled” “json.args”, “json.formatter”, “json.output” options but was unable to get a .ndjson without triggering the search for the standalone formatter executable.
EG:
"json": { "enabled": true, "args": ["cucumber-report-json-formatter.js"], "output": "cucumber-report.json" }
"json": { "enabled": true, "args": ["cucumber-report-json-formatter.js"], "formatter": "/formatter/", "output": "cucumber-report.json" }
etc…
Versions
- Cypress version: 10.3.0
- Preprocessor version: 11.4.0
- Node version: 14.19.3
Checklist
- I’ve read the FAQ.
- I’ve read Instructions for logging issues.
- I’m not using
cypress-cucumber-preprocessor@4.3.1
(package name has changed and it is no longer the most recent version, see #689).
Issue Analytics
- State:
- Created a year ago
- Comments:8 (1 by maintainers)
Thanks @badeball I got it working.
For anyone in future, I am using the npm package cucumber-json-report-formatter (https://github.com/Vitalizzzer/cucumber-json-report-formatter) to avoid the .exe installation.
With that package, I wrote a short script to operate the formatter (report-formatter.js):
And then with configuration:
Final step is a command to run my html report which is user preference.
Thanks again!
There’s a lot of things to address here…
If you only require the NDJSON output, you can simply configure
{ "messages": { "enabled": true } }
and that’s it. Then you have a NDJSON file, without the need of external dependencies.Configuring
{ "json": { "formatter": "/formatter/" } }
is never correct, because you have no executable named/formatter/
on your system (I checked).If you want to process the NDJSON using a custom JS-script, you can configure
{ "json": { "enabled": true, "formatter": "node", "args": ["cucumber-report-json-formatter.js"] } }
.Edit: You can probably also create an executable script with a shebang and configure something like
{ "json": { "enabled": true, "formatter": "./cucumber-report-json-formatter.js" } }
.