Antontelesh / mochawesome-merge

Merge several Mochawesome JSON reports
MIT License
85 stars 16 forks source link

Inconvenient usage for HTML generation #56

Closed rkrisztian closed 4 years ago

rkrisztian commented 4 years ago

I've been following this guide (the CLI way): https://www.npmjs.com/package/mochawesome-merge#cypress But it puts report files all over the place. I'd like all files ideally be in cypress/results. For example like this:

RESULTS_DIR=cypress/results

mochawesome-merge $RESULTS_DIR/mochawesome*.json --output $RESULTS_DIR/all.json
marge --reportDir $RESULTS_DIR --reportFilename mochawesome.html $RESULTS_DIR/all.json

As you could see, I had to add quite some additional code so that the end result is still mochawesome.html. Partly because mochawesome does not follow a unique naming for the JSON files, that is, the first file isn't numbered. Ideally I would like to have a command like this:

# Dream command that fits into `package.json` as a post-script:
mochawesome-merge cypress/results/*.json --saveHtml --reportDir cypress/results

(Something like that, whatever fits best to the tool.)

Could you please provide us with something like that? Thanks in advance.

Antontelesh commented 4 years ago

Generating html is a responsibility of mochawesome report generator (marge).

mochawesome-merge exists to combine several json reports into one.

I would recommend you to split these two tasks into two commands if one command does not look beautiful for you

rkrisztian commented 4 years ago

In the meantime I've realized that post- and pre- hooks do not run if the hooked command does not exit with success. So I ended up using more bash scripting.

I think it is kind of unfortunate that we got 3 tools for one single task: generating an HTML report for my whole Cypress execution:

This makes the complexity of project setups somewhat more than desired.

Nevertheless, I realize now it's not your tool's problem. I think it's more like a collective problem of all the tools involved. Or I'm thinking about this problem incorrectly, that I'm trying to fit an ecosystem of tools into one single NPM script line, which is the wrong thing to do.

Anyways, thanks for the info.