I was just having this exact issue the other day, thanks for the catch Papandreou! You just saved me some serious time.
-Chad From: [email protected] [mailto:[email protected]] On Behalf Of papandreou Sent: Monday, November 05, 2012 3:15 AM To: [email protected] Subject: [nodejs] Re: testing mongoose validation with vows It's actually a conscious design choice in vows, but I agree that it's a mistake. In the async case (last time I checked) it looks at the arity of your vow function (function.length), and if it takes less than two arguments, it assumes that you don't want the error passed to your function, just the "result", and that you want to classify it as an error every time an error is passed to this.callback. I guess the underlying assumption is that an async function will always deliver a result to its callback, but it's clearly too magic. It has caused a lot of wtfs for me and my team. The "fix" is to add a bogus 2nd argument to your vow function. Best regards, Andreas Lind Petersen (papandreou) On Sunday, November 4, 2012 12:07:59 PM UTC+1, Alberto Gori wrote: I discovered that the problem is not inherent to mongoose validation method, but to vows. Incredibly vows fails to manage Error in callback. For example: 'this model': { topic: function() {this.callback(new Error('error!!!'))} 'should throw an error': function(e) {asser.ok(e);} } this very simple test fails with > An unexpected error was caught: Error: error! I thought vows was a solid test library...what happened? -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
