javascript - Mocha test factorization and backtrace -


i run many mocha tests :

it('should fail blabla', function () {     return <functionthatreturnsapromise>()         .then(function () {             assert(false);         }, function (err) {             assert.strictequal(err.message, 'foobar undefined');             assert.strictequal(err.code, 'eundefinedfoobar');         }); }); 

the things vary among tests function, code , message.

i wanted factorize code this:

function shouldberejected(promise, code, message) {     return promise         .then(function () {             assert(false);         }, function (err) {             assert.strictequal(err.code, code);             assert.strictequal(err.message, message);         }); } (...) it('should fail blabla', function () {     return shouldberejected(<functionthatreturnsapromise>(),                             'eundefinedfoobar', 'foobar undefined'); }); 

it works when tests failed, backtraces reference shouldberejected function , so, i'm losing information real test failed.
there way more "intelligent" backtrace pointing shouldberejected calls indirectly raise error? maybe capturestacktrace somewhere?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -