Use toMatchText function when you want to check that an element's text matches the expected text with regular expression
example
// could be used with Promise<ElementHandle>awaitexpect(page.$('.alert')).toMatchText(/[S|s]uccess/);// or with ElementHandleconsttoastElement = awaitpage.$('.alert);awaitexpect(toastElement).toMatchText(/[S|s]uccess/);// or using an array of page and selectorawaitexpect([page, '.alert']).toMatchText(/[S|s]uccess/);
Use
toMatchText
function when you want to check that an element's text matches the expected text with regular expression