Week 7, day 3
APIs are proving to be a tough but interesting nut to crack.
We've also started using Protractor for end-to-end feature testing for Angular JS. All these new names are blowing our minds but it's seriously amazing what these apps can do, I am so in love with the way Protractor actually opens a browser window and carries out all the commands you tell it to.
describe('GitHub profile finder', function() {
var searchBox = element(by.model('searchCtrl.searchTerm'))
var searchButton = element(by.className('btn'))
beforeEach(function() {
browser.get('http://localhost:3000');
})
it('has a title', function() {
expect(browser.getTitle()).toEqual('Github user search');
});
it('finds profiles', function() {
searchBox.sendKeys('spike01');
searchButton.click();
var profiles = element.all(by.repeater('user in searchCtrl.searchResult.items'));
expect(profiles.last().getText()).toEqual('spike01');
});
});
An e2e Protractor feature test for our Github user search web app.
Using things like Postman helps immensely in testing what an API call will return, to debug and to eventually get to what you want.
Written on April 29, 2015