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

Configure xunit output filename through env #3621

Closed
1 task done
paulmelnikow opened this issue Dec 16, 2018 · 2 comments
Closed
1 task done

Configure xunit output filename through env #3621

paulmelnikow opened this issue Dec 16, 2018 · 2 comments
Labels
area: reporters involving a specific reporter type: feature enhancement proposal

Comments

@paulmelnikow
Copy link

Prerequisites

Description

I want to run the xunit reporter while in CI, and the spec reporter in dev. I'm using mocha-env-reporter to accomplish this. In CI I set the mocha_reporter environment variable in production and it switches the reporter.

However I also need to set the filename for each test suite. With mocha-junit-reporter I can do this with the MOCHA_FILE environment variable, however with the built-in xunit reporter I have to do it on the command line. This is inconvenient because it requires duplicating a bunch of parameters on the mocha command line into the CI config.

It would be helpful to be able to configure the output file for the xunit reporter through the environment, in the same way I can with mocha-junit-reporter.

@paulmelnikow
Copy link
Author

I just learned https://github.com/peerigon/xunit-file exists for the same purpose.

I've used Mocha for a long time and really like it. After some recent experiences with other test tools, I appreciate it even more. 😄

That said, config and reporters can be frustrating and fiddly to manage, especially across many small projects.

I was glad to hear about upcoming improvements to the config in #3612 and hoping there are more to come. I know often there's a goal to push use cases out to plugins, and appreciate that. I'm glad that Mocha does not take as much install footprint as, say, Jest.

However there are some things, like a reliable way to write reports to a file, which are not specialized, and really belong in core. If there's interest, I'd be happy to put some work into documenting and improving ease of use in this area.

@outsideris outsideris added type: feature enhancement proposal area: reporters involving a specific reporter labels Dec 17, 2018
@juergba
Copy link
Contributor

juergba commented Aug 14, 2021

You can use the js config file .mocharc.js for that:

  • define your own environment variables
  • set reporter and reporter-option via process.env in your .mocharc.js.

@juergba juergba closed this as completed Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: reporters involving a specific reporter type: feature enhancement proposal
Projects
None yet
Development

No branches or pull requests

3 participants