javascript - Mocha js tests not showing diff when strings not equal -


i have simple unit test assert string correct shows me test name failed, not diff of expected , actual results. example, here silly test code:

describe('stackoverflow', function(){     it('should simple', function() {         var somevalue = 'a' + 1 + 2;         assert.equal('a3', somevalue);     }); }); 

the output isn't helpful:

$ mocha    stackoverflow     1) should simple   <--- line red 

yes can see test failed can't see why. i'd see like:

$ mocha    stackoverflow     1) should simple         expected: 'a3'        actual  : 'a12' 

is there i'm doing wrong?

it because had test afterwards had no timeout set (because slow) , uses async pattern wasn't calling done()

here test.js demonstrates problem seeing (i've deleted unnecessary junk):

var assert = require("assert");  describe('basic', function(){     it('should simple', function() {         var somevalue = 'a' + 1 + 2;         assert.equal('a3', somevalue);     }); });  describe('slow', function(){     it('should not explode', function(done) {         this.timeout(0); // because takes ages     }); }); 

the solution make sure call done() in async test:

var assert = require("assert");  describe('basic', function(){     it('should simple', function() {         var somevalue = 'a' + 1 + 2;         assert.equal('a3', somevalue);     }); });  describe('slow', function(){     it('should not explode', function(done) {         this.timeout(0); // because takes ages         done();     }); }); 

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) -