feat: add normalized target for HTML entities

This commit is contained in:
Pengoose 2024-12-10 11:34:48 +09:00
parent be27666a2f
commit 2c903ee771
2 changed files with 2 additions and 2 deletions

View file

@ -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;

View file

@ -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);
} }