expect-playwright
expect-playwright copied to clipboard
toMatchText failed due to whitespaces
Hi guys,
I replaced the deprecated method toHaveText with the new one toMatchText and many of the tests failed. The reason for the failure is the presence of whitespace.
For example, this code is going to fail:
<button>
<i class="click-icon"></i>
<span>Click here</span>
</button>
------------------------
await expect(page).toMatchText('button', 'Click here');
Is there an option to modify toMatchText to run trim on textContent?
@yotov toMatchText supports regex for partial string matching. This should work.
await expect(page).toMatchText('button', /Click here/);