Skip to content
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

mochawesome custom reporter support #2

Open
gabrielthomasjacobs opened this issue May 4, 2021 · 7 comments
Open

mochawesome custom reporter support #2

gabrielthomasjacobs opened this issue May 4, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@gabrielthomasjacobs
Copy link
Contributor

gabrielthomasjacobs commented May 4, 2021

I'm trying to setup mochawesome to report the results, but I cannot get any output to be generated.

I've tried the default script:
mocha-vite-puppeteer --reporter mochawesome

As well as specifying a json file which looks like this:

{ "html": true }

The tests run and pass, but no output files are generated.
I've tested all of the other built-in reporters (dot, json, etc.) which all work and the other custom reporter, mocha-junit-reporter, is outputting a file correctly.

I tried debugging and following the reporter lookup functions you've made, but things went a bit over my head...

edit: using mochawesome version 6.2.2

@larsthorup
Copy link
Owner

Thank you for the bug report. You are right, and it seems like I only had this partially working. Sorry about that! I will remove the mention of "mochawesome" from README.md for now, and then investigate the issue further. How urgent is this issue for you?

@gabrielthomasjacobs
Copy link
Contributor Author

Hi, thank you for the quick response! It's not too urgent, I will go with the xml reporter option for the time being.

I am curious though, would allowing a mocharc.json file to be forwarded to the mocha instance be too complicated?
I know the mocha instance is able to handle merging configs.

Perhaps this would remove the need to explicitly support reporters and other configs?

@larsthorup larsthorup added the enhancement New feature or request label May 4, 2021
@larsthorup
Copy link
Owner

Thx. Could you create a separate issue for using mocharc.json over explicit CLI options, as that appears to be a separate improvement in its own right?

I have marked this issue with "enhancement" and will keep it open.

@larsthorup larsthorup changed the title mochawesome not generating output mochawesome custom reporter support May 4, 2021
@gabrielthomasjacobs
Copy link
Contributor Author

gabrielthomasjacobs commented Jul 6, 2021

I think I understand the relationship between all of the pieces in the project a bit better, but please let me know if I don't...

But I think it might be possible for us to "intercept" when "mochawesome" is specified as a reporter and then handle it by replacing "mochawesome" with "json". When the tests complete and the output comes back, it'll be in string/JSON form, if we can intercept this output and do a JSON.parse(), we should be able to just do mochawesome.create(outputObj) to have mochawesome-report-generator create the output.

I can start creating a prototype PR and testing, but I would need some direction for when/how the results are logged. I tried exploring a bit, but I can't seem to find it....

@larsthorup
Copy link
Owner

larsthorup commented Jul 7, 2021

Good suggestion, but unfortunately I don't think that will work. I assume that "outputObj" here is Mocha's output object, which contains a lot of self references (e.g. tests reference suites, and suites reference tests). And the "json" reporter only serializes a tiny bit of this object, which is the reason why this project includes the mochaProtocolReporter so we can include more of Mocha's objects and "recreate" some of the self references in mochaProtocolPlayer.

I believe the right strategy is to figure out which further properties of Mocha's output object is needed by mochawesome, and then add those to the mochaProtocolReporter and -Player.

@gabrielthomasjacobs
Copy link
Contributor Author

Using the mochawesome reporter, if I breakpoint after the tests run, the mochaProtocolPlayer.reporter.output seems to be almost in a good shape to be useful.

There are a few issues though, within that object, each suite object needs a "_timeout" key/value and it seems that all of the specs are reporting as skipped. Not really sure why....

@larsthorup
Copy link
Owner

I don't know either - more debugging required, I guess - happy to assist with ideas, if you share a fork with a specific question!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants