Use toContainText function when you want to check that an element's text contains the expected string or substring
example
// could be used with Promise<ElementHandle>awaitexpect(page.$('.alert')).toContainText('Success');// or with ElementHandleconsttoastElement = awaitpage.$('.alert);awaitexpect(toastElement).toContainText('Success');// or using an array of page and selectorawaitexpect([page, '.alert']).toHaveText('Success');// also you can check text ignoring case sensitiveawaitexpect(page.$('.alert')).toHaveText('success', {ignoreCase:true})
Use
toContainText
function when you want to check that an element's text contains the expected string or substring