You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am just starting to use this library, and trying to understand how vows knows if my codeblock is asynchronous or not. It seems like in even the simplest case it fails to work as I would expect.
// my-first-test.jsvarvows=require('vows'),assert=require('assert');vows.describe('Deep Thought').addBatch({'part 1': {topic: newObject({foo:'bar'}),'should know the answer to the ultimate question of life': function(deepThought){setTimeout(function(){assert.equal(obj.foo,'br');},1000);setImmediate(function(){assert.equal(obj.foo,'ba');});}},'part 2': {topic: newObject({foo:'baz'}),'should know the answer to the ultimate question of life': function(obj){setTimeout(function(){assert.equal(obj.foo,'br');},1000);setImmediate(function(){assert.equal(obj.foo,'ba');});}}}).run();
what happens, is that upon the first assert error, the test framework conks out. Ideally, upon each assertion error, they could get trapped and the test library could move on to the next test.
Is it possible to test asynchronous code like this? Am I missing something?
as you can see, the output of
$ node my-first-test.js
is
·· ✓ OK » 2 honored (0.009s)
assert.js:89
throw new assert.AssertionError({
^
AssertionError: expected {expected},
got {actual} ({operator})
at Immediate._onImmediate (/Users/amills001c/WebstormProjects/ORESoftware/suman/competition/vows/ex1.js:14:24)
at processImmediate [as _immediateCallback] (timers.js:383:17)
I am aware, that with domains being deprecated in Node core, it may be impossible to trap errors that are thrown asynchronously...
but if I fix so that the assert's don't throw:
varvows=require('vows'),assert=require('assert');vows.describe('Deep Thought').addBatch({'part 1': {topic: newObject({foo:'bar'}),'should know the answer to the ultimate question of life': function(obj){setTimeout(function(){assert.equal(obj.foo,'bar');},1000);setImmediate(function(){assert.equal(obj.foo,'bar');});}},'part 2': {topic: newObject({foo:'baz'}),'should know the answer to the ultimate question of life': function(obj){setTimeout(function(){assert.equal(obj.foo,'baz');},1000);setImmediate(function(){assert.equal(obj.foo,'baz');});}}}).run();
then I get
·· ✓ OK » 2 honored (0.008s)
The text was updated successfully, but these errors were encountered:
I am just starting to use this library, and trying to understand how vows knows if my codeblock is asynchronous or not. It seems like in even the simplest case it fails to work as I would expect.
what happens, is that upon the first assert error, the test framework conks out. Ideally, upon each assertion error, they could get trapped and the test library could move on to the next test.
Is it possible to test asynchronous code like this? Am I missing something?
as you can see, the output of
$ node my-first-test.js
is
I am aware, that with domains being deprecated in Node core, it may be impossible to trap errors that are thrown asynchronously...
but if I fix so that the assert's don't throw:
then I get
The text was updated successfully, but these errors were encountered: