Collections and Event Emitter #266

arb opened this Issue Feb 6, 2013 · 1 comment


None yet

2 participants

arb commented Feb 6, 2013

I asked this question on StackOverflow, but I thought I'd probably have a better change of getting an answer here. I would like to iterate over a collection of objects and use that object as the topic of N number of vows.

My thought was to use an event emitter in the topic and emit an event for each item in the collection and pass the current object to the vows. This seems to work as expected, but there is always a test case that is listed as "1 Errored" but doesn't give me much information about it.

Here is the code snippet

'the variations objects': {
  topic: function() {
    var promise = new(events.EventEmitter),
      variations = JSON.parse(body).variations;

    for(var i = variations.length - 1; i >= 0; i--) {
      promise.emit("success", variations[i]);

    return promise;
  'should have an x': function(topic) {
  'should have an action on the add_to_cart object if the product is IN_STOCK': function(topic) {
    if( === 'TEST'){

The correct number of tests execute and the results are correct, but there is always a nagging "1 Error" result hanging around.

Is this even the right way to approach this? For the moment, I just iterate over a collection and call .addBatch() on the suite and pass in a vows object with the topic set accordingly.

I saw a PR that added the ability to listed for multiple events, and I tried that route, but none of my events fired and nothing was happening.

Is using events in this way recommended or should I stick to iterative over the collection and dynamically adding tests to the suite?


Not sure but this seems related to #264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment