O'Reilly logo

Angular Test-Driven Development - Second Edition by Md. Ziaul Haq

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

Diving into our comment application

Now that the setup and approach have been decided, we can start our first test. From a testing point of view, as we will be using a top-down approach, we will write our Protractor tests first and then build the application. We will follow the same TDD life cycle we have already reviewed: test first, make it run, and make it better.

Test first

The scenario given is already in a well-specified format and fits our Protractor testing template:

describe('', () => { 
    describe('', () => { 
     beforeEach(() => { 
     }); 
 
      it('', () => { 
      }); 
    }); 
}); 

Placing the scenario in the template, we get the following code:

describe('Given I am posting a new comment', () => { describe('When I push the submit button', () => { beforeEach(() => ...

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