Skip to content

Commit

Permalink
fix: Improve third-party reporters example (#104)
Browse files Browse the repository at this point in the history
* Update readme

* Remove unused file

* Ref .mocharc.json

* One reporter, one runner

* Add actual failing test

* Link to tutorial

* Tutorial will cover more details ;)
  • Loading branch information
mark-wiemer authored Jan 3, 2025
1 parent 16a5f6b commit 48f723f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions packages/third-party-reporter/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Third party reporter
# Third-party reporter

Full documentation about it [here](https://github.com/mochajs/mocha/wiki/Third-party-reporters).
Mocha supports third-party reporters that can support advanced or specific use-cases. A reporter wraps around a [Runner](https://mochajs.org/api/runner) object and optionally listens to the events it emits.

To use a reporter published on npm (e.g., lcov-reporter), install it locally and set `--reporter lcov-reporter`.
To use a reporter published on npm (e.g., lcov-reporter), install it locally and set `--reporter lcov-reporter`. Alternatively, you can set the reporter in `.mocharc.json` as we've done here.

It is a very similar setup for `third party UI's`, for more details see [here](https://github.com/mochajs/mocha/wiki/Third-party-UIs).
It is a very similar setup for [third party UI's](https://github.com/mochajs/mocha/wiki/Third-party-UIs).

## Commands
For more details, including a list of which argument types go with which runner event, see [Tutorial: Create a Custom Reporter](https://mochajs.org/api/tutorial-custom-reporter).

- `npm test` - run our tests using the local `.mocharc.json` config file. They are run from the default location (`/test`) with the reporter found in `src/my-reporter.js`. In this example there is 1 failing test included, to demonstrate handling.
## Commands

- `npm test` - run our tests using the local `.mocharc.json` config file. They are run from the default location (`/test`) with the reporter found in `src/my-reporter.js`.
3 changes: 0 additions & 3 deletions packages/third-party-reporter/index.js

This file was deleted.

4 changes: 4 additions & 0 deletions packages/third-party-reporter/test/unit/my-reporter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ describe('Third party reporter usage', () => {
it('should equal true', () => {
equal(true, true);
});

it('should fail', () => {
equal(true, false);
})
});

0 comments on commit 48f723f

Please sign in to comment.