P粉0186537512023-08-18 00:30:47
The correct way to use the expect function with the .not.toBeEmpty matcher is to put parentheses after .not.toBeEmpty to call the assertion and compare it with the actual value.
await expect(page.locator('div.welcome-content > h2')).not.toBeEmpty()
If you are using playwright's own assertion library, you can do this:
await expect(page.locator('div.welcome-content > h2')).toHaveText(text => text.length > 0);