Skip to content

Commit

Permalink
Built in support for xunit file output (closes #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
aldeed committed Mar 29, 2017
1 parent 9614506 commit 86bde24
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ The default Mocha reporter for server tests is the "spec" reporter. You can set
$ SERVER_TEST_REPORTER="dot" meteor test --once --driver-package dispatch:mocha
```

#### Generate an XUnit file for server tests

To generate an XUnit file, set `SERVER_TEST_REPORTER` to `xunit` and set `XUNIT_FILE` to the full path + filename, e.g., `$PWD/unit.xml`.

```bash
$ SERVER_TEST_REPORTER=xunit XUNIT_FILE=$PWD/unit.xml meteor test --once --driver-package dispatch:mocha
```

### Run with a different client reporter

The default Mocha reporter for client tests is the "spec" reporter. You can set the `CLIENT_TEST_REPORTER` environment variable to change it.
Expand Down
4 changes: 3 additions & 1 deletion runtimeArgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ export default function setArgs() {
TEST_PARALLEL,
TEST_SERVER,
TEST_WATCH,
XUNIT_FILE,
} = process.env;

const runtimeArgs = {
mochaOptions: {
grep: MOCHA_GREP || false,
invert: !!MOCHA_INVERT,
reporter: MOCHA_REPORTER || 'tap',
reporter: MOCHA_REPORTER || 'spec',
serverReporter: SERVER_TEST_REPORTER,
clientReporter: CLIENT_TEST_REPORTER,
xUnitOutput: XUNIT_FILE,
},
runnerOptions: {
runClient: (TEST_CLIENT !== 'false' && TEST_CLIENT !== '0'),
Expand Down
6 changes: 4 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { startBrowser } from 'meteor/aldeed:browser-tests';
import setArgs from './runtimeArgs';

const { mochaOptions, runnerOptions } = setArgs();
const { grep, invert, reporter, serverReporter } = mochaOptions || {};
const { grep, invert, reporter, serverReporter, xUnitOutput } = mochaOptions || {};

// Since intermingling client and server log lines would be confusing,
// the idea here is to buffer all client logs until server tests have
Expand Down Expand Up @@ -88,7 +88,9 @@ function serverTests(cb) {
// We need to set the reporter when the tests actually run to ensure no conflicts with
// other test driver packages that may be added to the app but are not actually being
// used on this run.
mochaInstance.reporter(serverReporter || reporter);
mochaInstance.reporter(serverReporter || reporter, {
output: xUnitOutput,
});

mochaInstance.run((failureCount) => {
exitIfDone('server', failureCount);
Expand Down

0 comments on commit 86bde24

Please sign in to comment.