Book Image

Learning Behavior-driven development with Javascript

Book Image

Learning Behavior-driven development with Javascript

Overview of this book

Table of Contents (17 chapters)
Learning Behavior-driven Development with JavaScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Testing the GET order feature


Let's create a brand new package in a different project. Why a different project? We have explored the idea that the API deserves its own set of features and that we should decouple it from the core layer using a well-defined interface that we will mock. Since it is a different problem domain, we should create a different package. This way, we can develop them and manage their life cycles in an independent fashion.

Tip

For a simple project like this, it is OK if you prefer to simply put both layers in the same package.

So, let's create a mycafe-api/ folder with the same project layout we have been using so far. Initialize the project by creating a basic package.json file, and then, run the following commands to install the packages we need:

$ ~/mycafe-api> npm install --save-dev chai sinon sinon-chai chai-as-promised request mocha
$ ~/mycafe-api> npm install --save express q

Note that I am installing express as a runtime dependency (version 4.x). This is...