I have this case where I think I want to have nested it() test cases in a Mocha test. I am sure that this is wrong, and I do not see any recommendations to do what I am doing, but in fact I do not know the best way at the moment -
Basically, I have a “parent” test, and inside the parent test there is a forEach loop with all the “child” tests:
it('[test] enrichment', function (done) { var self = this; async.each(self.tests, function (json, cb) { //it('[test] ' + path.basename(json), function (done) { var jsonDataForEnrichment = require(json); jsonDataForEnrichment.customer.accountnum = "8497404620452729"; jsonDataForEnrichment.customer.data.accountnum = "8497404620452729"; var options = { url: self.serverURL + ':' + self.serverPort + '/event', json: true, body: jsonDataForEnrichment, method: 'POST' }; request(options,function (err, response, body) { if (err) { return cb(err); } assert.equal(response.statusCode, 201, "Error: Response Code"); cb(null); }); //}); }, function complete(err) { done(err) }); });
as you can see, two separate lines are commented out - I want to include them so that I can easily see the results of each individual test, but then I get such an uncomfortable situation when you run a callback for a test along with a callback for async.each.
Has anyone seen this situation time before and knows a good solution where a tester can easily see the results of each test in a cycle?
source share