acuminous / yadda

A BDD javascript library
412 stars 73 forks source link

Step failure hook #141

Closed Ashthos closed 8 years ago

Ashthos commented 9 years ago

We are using Yadda along with Protractor to test an angular UI. One thing we would like to do on step failure is to take a screenshot of the offending page.

We have attempted to hook into Jasmine in order to discover step failures, but have so far failed to do so.

Probably best would be a an event we can subscribe to which is similar to ON_STEP_FAIL.

cressie176 commented 9 years ago

I've not used Protractor, if you can create a sample project I'll take a look

cressie176 commented 9 years ago

Think I can do this for errors passed via an async step callback, or for errors thrown from a sync step. What will be harder would be to catch errors thrown from a truly async step. Yadda can be used in node or browser environments so I can't assume domain / global errors handlers.

Would this be sufficient?

Ashthos commented 8 years ago

Hi, Apologies for the slow reply.

I actually worked around this by creating a custom jasmine reporter, so we implemented a module that exposes the following contract:

module.exports = {
    stepStart: stepStart, // Our own way of notifying the reporter that a step is starting
    specDone: stepFinished, // Jasmine
    suiteDone: scenarioFinished // Jasmine
};

This allows us to be notified of each step result before yadda is handled back control. We utilise this in a singleton pattern so the instance is also aware of the steps and scenarios of yadda.

Kind regards

Ash