How to use the Test function from mocha
Find comprehensive JavaScript mocha.Test code examples handpicked from public code repositorys.
mocha.Test is a class that represents a single test case in a Mocha test suite.
GitHub: codeceptjs/CodeceptJS
116 117 118 119 120 121 122 123 124 125
} if (child.scenario) { const tags = child.scenario.tags.map(t => t.name); const title = `${child.scenario.name} ${tags.join(' ')}`.trim(); const test = new Test(title, async () => runSteps(child.scenario.steps)); test.tags = suite.tags.concat(tags); test.file = file; suite.addTest(scenario.test(test)); }
706
0
106
+ 7 other calls in file
3 4 5 6 7 8 9 10 11 12
// for reporting const reportDirectory = path.resolve(__dirname, `../execution-report`) // mocha setup const Test = Mocha.Test; const suiteInstance = Mocha.Suite; const mocha = new Mocha({
1
7
3
How does mocha.Test work?
mocha.Test
is not a valid class or function in the Mocha testing framework, but the closest matching class is mocha.Test
which represents a test case and provides methods for setting up pre-conditions, running tests, and reporting test results.
41 42 43 44 45 46 47 48 49 50
* Runs all tests */ RamlTest.prototype.getTest = function() { var self = this; return new Mocha.Test(self.name, function() { var response = null; describe(self.name, function () { before(function(done) { var requestConfig = {};
1
4
29
Ai Example
1 2 3 4 5
describe("my test suite", function () { it("should do something", function () { // test logic here }); });
This defines a test suite with the name "my test suite" and a single test case with the name "should do something". When run, Mocha will execute the logic in the test case and report the results.
mocha.utils is the most popular function in mocha (4328 examples)