feat: add normalized target for HTML entities
This commit is contained in:
parent
be27666a2f
commit
2c903ee771
|
|
@ -83,7 +83,7 @@ export function cacheNormalizedWhitespaces() {
|
||||||
export function normalizeWhiteSpace(text: string): string {
|
export function normalizeWhiteSpace(text: string): string {
|
||||||
let result = normalizedWhitespaceCache?.get(text);
|
let result = normalizedWhitespaceCache?.get(text);
|
||||||
if (result === undefined) {
|
if (result === undefined) {
|
||||||
result = text.replace(/\u200b/g, '').trim().replace(/\s+/g, ' ');
|
result = text.replace(/\u200b/g, '').replace(/ /g, ' ').trim().replace(/\s+/g, ' ');
|
||||||
normalizedWhitespaceCache?.set(text, result);
|
normalizedWhitespaceCache?.set(text, result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ export function toHaveValue(
|
||||||
options?: { timeout?: number },
|
options?: { timeout?: number },
|
||||||
) {
|
) {
|
||||||
return toMatchText.call(this, 'toHaveValue', locator, 'Locator', async (isNot, timeout) => {
|
return toMatchText.call(this, 'toHaveValue', locator, 'Locator', async (isNot, timeout) => {
|
||||||
const expectedText = serializeExpectedTextValues([expected]);
|
const expectedText = serializeExpectedTextValues([expected], { normalizeWhiteSpace: true });
|
||||||
return await locator._expect('to.have.value', { expectedText, isNot, timeout });
|
return await locator._expect('to.have.value', { expectedText, isNot, timeout });
|
||||||
}, expected, options);
|
}, expected, options);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue