May 2019
Intermediate to advanced
496 pages
10h 38m
English
The three expectations in this test will be needed every time we define a new text field. A simple way to avoid repeating each expectation is to extract an arrow function that runs all three as a group:
const expectToBeInputFieldOfTypeText = formElement => { expect(formElement).not.toBeNull(); expect(formElement.tagName).toEqual('INPUT'); expect(formElement.type).toEqual('text');};
Define this function above your test and replace the expectations in your test with a call to this function.
Read now
Unlock full access