Image for post
Image for post
Describe/It statements should always be written in human-readable grammar.

Unit Tests: More Readable Describe/It Statements in Protractor/Jasmine

How to create human-readable test failures

// Protractorjs in ES6describe('the search function', () => {
it('returns an array of strings that contain a given string', () => {
[...insert test here...]
}
})
FAIL: The search filter returns an array of results that contain a given stringExpected [the right thing], got [the wrong thing].

But what about multiple ‘it’s?

describe('the search function', () => {
it('returns an array of strings that contain a given string', () => {
[...insert test here...]
}
it('returns an empty array when there are no matches', () => {
[...insert test here...]
}
})
FAIL: The search filter returns an array of results that contain a given string.Expected [the right thing], got [the wrong thing].
FAIL: The search filter returns an empty array when there are no matches.
Expected [another right thing], got [another wrong thing].

Senior Software Engineer at Skookum. Adrenaline Junkie. Build, Break, Boom.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store