typescript - mocha test the promise, catch exception case -


i have test :

it('should not save user if exists', ()=>{     var user : user = {username : 'jack', name : 'lenon'};     var user1 : user = {username : 'jack', name : 'linon'};     return repository.saveuser(user)     .then((user:user)=>{         return repository.saveuser(user1)     }).then((user : user)=>{           expect('second ').equals('');         })         .catch((err) =>{             expect(err).equals("a user username exist in database");         }); }); 

the idea test repository rejecting save second user same name. works, not happy @ way force failure in "then". there better way that?


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -