Closed
Bug 976810
Opened 10 years ago
Closed 10 years ago
Async errors in Promise.then() in unit test getting lost
Categories
(Add-on SDK Graveyard :: General, defect)
Add-on SDK Graveyard
General
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: willmarquardt, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:27.0) Gecko/20100101 Firefox/27.0 (Beta/Release) Build ID: 20140212131424 Steps to reproduce: Created a test module with the following code exports["test rest get article"] = function(assert, done) { rest.get('article', articleUrl).then(function(article) { fakeVar.length; console.log('Should see console.error above'); done(); } } Actual results: Test failed after it timed out with nothing printed to the console. Expected results: Test should have failed immediately (after rest.get() ) with both the error and the log printed to the console.
Comment 1•10 years ago
|
||
The code you've entered is invalid, it's missing a closing bracket. Even if it weren't when an exception is thrown in a promise handler it becomes a rejected promise which you aren't handling. As this is all async code it's difficult to impossible for the test harness to handle this automatically except by timing out. You need to do something like this: exports["test rest get article"] = function(assert, done) { rest.get('article', articleUrl).then(function(article) { fakeVar.length; console.log('Should see console.error above'); }).then(done, function(error) { assert.fail(error); done(); }); }
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
Reporter | ||
Comment 2•10 years ago
|
||
Awesome, thanks for the helpful code. Sorry for posting as a bug.
Comment 3•10 years ago
|
||
Never be sorry to post a bug, it's better have people willing to help us to fix issues that discover all of them by ourselves. :)
Comment 4•10 years ago
|
||
Side-note: bug 998277 might actually help here.
You need to log in
before you can comment on or make changes to this bug.
Description
•