Last active
November 23, 2022 08:22
-
-
Save sauceaaron/6e69fe3de106ea3750b85175ca6c4985 to your computer and use it in GitHub Desktop.
Get test name and status in before / after hooks with mocha.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var assert = require("assert"); | |
| describe("tests with annotations", function() | |
| { | |
| it("should print the test name in a before hook", function() | |
| { | |
| assert(true); | |
| }); | |
| beforeEach("annotate before", function beforeEach() | |
| { | |
| console.log("[BEFORE:currentTest.title]", this.currentTest.title); | |
| console.log("[BEFORE:currentTest.fullTitle()]", this.currentTest.fullTitle()); | |
| }); | |
| afterEach("annotate after, function afterEach() | |
| { | |
| console.log("[AFTER:currentTest.title]", this.currentTest.title); | |
| console.log("[AFTER:currentTest.fullTitle()]", this.currentTest.fullTitle()); | |
| console.log("[AFTER:currentTest.state]", this.currentTest.state); | |
| }); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sauceaaron is it possible to get the test
configin before / after hooks with mocha.js