Skip to content

Commit

Permalink
add allure report for mocha tests (via #41)
Browse files Browse the repository at this point in the history
  • Loading branch information
just-boris authored and baev committed Aug 23, 2019
1 parent d3fa585 commit 4b8874b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pipeline {
}
post {
always {
allure results: [[path: '**/out/allure-results']]
deleteDir()
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/allure-mocha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build": "npm run lint && npm run compile",
"generate-report": "allure generate ./out/allure-results -o ./out/allure-report --clean",
"allure-report": "allure serve ./out/allure-results",
"test": "nyc mocha",
"test": "nyc node dist/test/runner",
"coverage": "codecov",
"lint": "eslint ./src ./test ./index.ts --ext .ts",
"lint-fix": "eslint ./src ./test ./index.ts --ext .ts --fix"
Expand All @@ -31,6 +31,7 @@
"dotenv": "^8.0.0",
"fs-jetpack": "^2.2.2",
"mocha": "^6.2.0",
"mocha-multi": "^1.1.1",
"mocha-typescript": "^1.1.17",
"nyc": "^14.0.0",
"prettier": "^1.17.0",
Expand Down
5 changes: 0 additions & 5 deletions packages/allure-mocha/test/mocha.opts

This file was deleted.

30 changes: 30 additions & 0 deletions packages/allure-mocha/test/runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// custom runner for mocha that allows to include a custom reporter
// which is not packed into an npm module
import Mocha from "mocha";
import glob from "glob";
import "source-map-support/register";

declare module "mocha" {
interface InterfaceContributions {
"mocha-typescript": never;
}
}

const mocha = new Mocha({
ui: "mocha-typescript",
timeout: 16000,
reporter: "mocha-multi",
reporterOptions: {
list: "-",
[require.resolve("../")]: {
stdout: "-",
options: {
resultsDir: "./out/allure-results"
}
}
}
});

glob.sync("dist/test/specs/**/*.js").forEach(file => mocha.addFile(file));

mocha.run(failures => process.exit(failures === 0 ? 0 : 1));

0 comments on commit 4b8874b

Please sign in to comment.