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

Onward and upward

Now that we have the first specification working, and it is end-to-end and unit tested, we can start the next specification. The next specification states that the user wants the ability to like a comment.

We will use the top-down approach and start our test from Protractor. We will continue to follow the TDD life cycle: test first, make it run, and make it better.

Test first

Following the pattern, we will start with a basic Protractor test template:

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

When we fill in the specification, we get the following:

describe('When I like a comment', () => { 
    beforeEach(() => { 
    }); 
 
    it('should then be liked', () => { 
      }); 
}); 

With the template in place, we are ready to construct ...

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