In the Response Content chapter in the Server Testing Patterns lesson, the chapter content alludes to use assert.include
to validate the response.
For our tests, once we retrieve the response from the server, we use
assert.include()
from the Chai library to check the response.
The first part of the chapter wants us to check that the content located in the h1 element with an id of #page-title contains the text ‘Messaging App’.
We want our home page (at
'/'
) to contain an<h1>
element. It should say ‘Messaging App’. Add an assertion within the “correct title” test using theparseTextFromHTML()
helper to check the response.
So obviously as per the lesson, I wrote the following:
assert.include(parseTextFromHTML(response.text, '#page-title'), 'Messaging App');
Doesn’t pass. What the solution is, is assert.equal
. Some possible solutions, either allow assert.include
or change the text to say something along the lines that you strictly want the h1 to equal …