fix(toHaveText): normalize zero width white space (#10623)
This commit is contained in:
parent
f05252874a
commit
127dacf5d4
|
|
@ -1129,7 +1129,7 @@ class ExpectedTextMatcher {
|
|||
private normalizeWhiteSpace(s: string | undefined): string | undefined {
|
||||
if (!s)
|
||||
return s;
|
||||
return this._normalizeWhiteSpace ? s.trim().replace(/\s+/g, ' ') : s;
|
||||
return this._normalizeWhiteSpace ? s.trim().replace(/\u200b/g, '').replace(/\s+/g, ' ') : s;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ test('should support toHaveText w/ text', async ({ runInlineTest }) => {
|
|||
const locator = page.locator('#node');
|
||||
// Should normalize whitespace.
|
||||
await expect(locator).toHaveText('Text content');
|
||||
// Should normalize zero width whitespace.
|
||||
await expect(locator).toHaveText('T\u200be\u200bx\u200bt content');
|
||||
});
|
||||
|
||||
test('pass contain', async ({ page }) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue