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

Make stats optional and off by default. #55

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @digitalbazaar/mocha-w3c-interop-reporter ChangeLog

## 1.10.0 - yyyy-mm-dd

### Added
- Report statistics can be enabled via the `stats` reporter option.

### Changed
- The statistics are no longer output by default.

## 1.9.0 - 2024-09-30

### Added
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ A helpers file can be specified to add project specific helpers to report templa

const helpers = {
upperCaseTitle(testTitle) {
return testTitle.toUpperCase();
return testTitle.toUpperCase();
}
};
export default helpers;
Expand All @@ -67,7 +67,7 @@ then specify the path to the helpers file in the `--reporter-options helpers="$P

Handlebars lets you use the helpers inside of templates like this:

```
```html
<td class="{{state}} {{getOptional optional}}">{{getStatusMark state}}</td>
```

Expand Down Expand Up @@ -107,9 +107,10 @@ The templates are written in [Handlebars](https://handlebarsjs.com/).

Most of the configuration options can be specified by command line options:

```
```sh
mocha tests/ --reporter @digitalbazaar/mocha-w3c-interop-reporter --reporter-options body=\"$PWD/body.hbs\",matrix=\"$PWD/matrix.hbs\",reportDir=\"$PWD/reports\",respec=\"$PWD/respecConfig.json\",title=\"Test Interoperability Report 1.0\",helpers=\"$PWD/templateHelpers.js\",suiteLog='./suite.log' --timeout 15000"
```

- `--reporter` - Specifies the reporter and is required.

- `--reporter-options` - Passes options to the reporter in the form `key=value[,key2=value[,...]]`.
Expand Down Expand Up @@ -137,10 +138,12 @@ mocha tests/ --reporter @digitalbazaar/mocha-w3c-interop-reporter --reporter-opt

- *templateData* - Is an optional reporter option that dumps the data used to make the HTML report as json.

- *stats* - Enable report statistics. Currently aggregates all matrices. Off by default.

The reporter also has an npx binary for creating test html manually from mocha suites.
This can be used to debug results with out having to rerun an entire test suite.

```
```sh
npx interopReporter makeReport --suiteLog=./suite.log --output=./reports/manualReport.html
```

Expand Down
3 changes: 2 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const getConfig = ({reporterOptions = {}} = {}) => {
join(templatesPath, 'matrix.hbs'),
statistics: reporterOptions.statistics ||
join(templatesPath, 'test-statistics.hbs'),
}
},
stats: !!reporterOptions.stats
};
};
6 changes: 4 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ function InteropReporter(runner, options = {}) {
try {
console.log('\n');
const stats = formatStats(this.stats);
stats.forEach(stat => console.log(stat));
if(config.stats) {
stats.forEach(stat => console.log(stat));
}
const reportHTML = await makeReport({
suite: this.suite,
stats,
stats: config.stats ? stats : [],
config
});
if(config.suiteLog) {
Expand Down
Loading