O'Reilly logo

Learning Behavior-driven Development with JavaScript by Enrique Amodeo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finishing our feature

We are almost done; we just need to finish our last scenario. First of all, we need a new DAO that is responsible for storing the messages. The real implementation of this DAO, perhaps, will not go to the database but will probably use the flash scope or the session scope of the web framework we are going to use. This does not matter conceptually as it is an object to access external data:

beforeEach(function () {
  this.orderStorage = newStorage();
  this.messageStorage = newStorage();
  this.orderSystem = orderSystemWith({
    order: this.orderStorage.dao(),
    message: this.messageStorage.dao()
  });
});

Now, we can create an example message factory in the test/support/examples/errors.js file:

'use strict'; module.exports = { badQuantity: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required