Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

toMatchText failed due to whitespaces #124

Open
yotov opened this issue Sep 10, 2021 · 1 comment
Open

toMatchText failed due to whitespaces #124

yotov opened this issue Sep 10, 2021 · 1 comment

Comments

@yotov
Copy link

yotov commented Sep 10, 2021

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?

@mskelton
Copy link
Member

@yotov toMatchText supports regex for partial string matching. This should work.

await expect(page).toMatchText('button', /Click here/);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants