I am using expect in typescript to write an assertion while writing a Then step definition using typescript in in playwright I have assigned an the class on this url https://www.gov.uk/help/accessibility-statement to confirm I can see accessibility statement when I land on the page.
I then get an undefined error when I run my tests.
Code written:-
import expect from "expect";
Then("I expect to be on the accessibility page", async function(
this: OurWorld
)
{
const {page} = this;
// eslint-disable-next-line no-debugger
const headMessage =await page?.$(".gem-c-title__text.govuk-heading-xl")
console.log(headMessage)
expect (headMessage).toContainEqual(("Accessibility statement")
);
});
I would like to check that the accessibility icon on the accessibility page contains the text accessibility.
The error I am getting back is this:-
× Then I expect to be on the accessibility page # step-definitions\feature.step-definitions.ts:28
Error: expect(received).toContainEqual(expected) // deep equality
Matcher error: received value must not be null nor undefined
Thank you for your help