-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Alternative custom reporter to mocha-multi #7931
Changes from all commits
f1d4e16
ac1c65b
5b32b1d
2803e3f
04159fb
8455b6c
4f2d5e1
2e33b0e
a065359
0f86c8f
5ddb301
b0ef2f5
9bd3968
940c519
71e4fe7
9a6738d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
"use strict"; | ||
|
||
const Mocha = require("mocha"); | ||
const MochaJUnitReporter = require("mocha-junit-reporter"); | ||
|
||
/** | ||
* Usage : | ||
* - Meant to be used to leverage Mocha's Spec reporter as well as mocha-junit-reporter for the test runs | ||
* - Provide the relative path to this file from your `sdk/service/package-folder/` as the reporter options to mocha | ||
* - Example - `--reporter ../../../common/tools/mocha-multi-reporter.js` | ||
* | ||
* Refer the following docs for more customizations on reporters | ||
* https://mochajs.org/api/tutorial-custom-reporter.html | ||
* | ||
* @class MultiReporter | ||
*/ | ||
class MultiReporter { | ||
constructor(runner) { | ||
// Spec reporter is provided as part of mocha library | ||
// Invoking the spec reporter with the runner | ||
new Mocha.reporters.Spec(runner); | ||
// Invoking mocha-junit-reporter to generate XML reports of test summaries for CI | ||
new MochaJUnitReporter(runner); | ||
} | ||
} | ||
|
||
module.exports = MultiReporter; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
--require ts-node/register | ||
--timeout 50000 | ||
--reporter mocha-multi | ||
--reporter-options spec=-,mocha-junit-reporter=- | ||
--reporter ../../../common/tools/mocha-multi-reporter.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logged #7933 |
||
--colors | ||
test/**/*.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--require ts-node/register | ||
--timeout 50000 | ||
--reporter mocha-multi | ||
--reporter-options spec=-,mocha-junit-reporter=- | ||
--reporter ../../../common/tools/mocha-multi-reporter.js | ||
--colors | ||
--exclude test/**/*.browser.ts | ||
test/**/*.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node", | ||
"test": "npm run build:test && npm run unit-test && npm run integration-test", | ||
"unit-test:browser": "echo skipped", | ||
"unit-test:node": "mocha test-dist/**/*.js --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-", | ||
"unit-test:node": "mocha test-dist/**/*.js --reporter ../../../common/tools/mocha-multi-reporter.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
One proposal to refactor is to move the reporter options to the rush-yaml scripts where we trigger the test scripts instead of |
||
"unit-test": "npm run unit-test:node && npm run unit-test:browser" | ||
}, | ||
"files": [ | ||
|
@@ -84,7 +84,6 @@ | |
"inherits": "^2.0.3", | ||
"mocha": "^6.2.2", | ||
"mocha-junit-reporter": "^1.18.0", | ||
"mocha-multi": "^1.1.3", | ||
"prettier": "^1.16.4", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^1.16.3", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to note here is that the
mocha-multi-reporter.js
file is not part of any project/utilities, it is an independent file and doesn't have apackage.json
of its own.Placed here(under
common/tools/
folder) only so that all the SDKs can leverage.SDKs are expected to import
mocha
andmocha-junit-reporter
as devDependencies and then use this.js
file as the reporter in the mocha test command inpackage.json
.