chore: unshift shortest whitespace prefix only (#33618)
This commit is contained in:
parent
77dee44984
commit
e24780f825
|
|
@ -126,7 +126,6 @@ function unshift(snapshot: string): string {
|
||||||
const match = line.match(/^(\s*)/);
|
const match = line.match(/^(\s*)/);
|
||||||
if (match && match[1].length < whitespacePrefixLength)
|
if (match && match[1].length < whitespacePrefixLength)
|
||||||
whitespacePrefixLength = match[1].length;
|
whitespacePrefixLength = match[1].length;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return lines.filter(t => t.trim()).map(line => line.substring(whitespacePrefixLength)).join('\n');
|
return lines.filter(t => t.trim()).map(line => line.substring(whitespacePrefixLength)).join('\n');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ function unshift(snapshot: string): string {
|
||||||
const match = line.match(/^(\s*)/);
|
const match = line.match(/^(\s*)/);
|
||||||
if (match && match[1].length < whitespacePrefixLength)
|
if (match && match[1].length < whitespacePrefixLength)
|
||||||
whitespacePrefixLength = match[1].length;
|
whitespacePrefixLength = match[1].length;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return lines.filter(t => t.trim()).map(line => line.substring(whitespacePrefixLength)).join('\n');
|
return lines.filter(t => t.trim()).map(line => line.substring(whitespacePrefixLength)).join('\n');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -659,3 +659,17 @@ test('should parse attributes', async ({ page }) => {
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not unshift actual template text', async ({ page }) => {
|
||||||
|
await page.setContent(`
|
||||||
|
<h1>title</h1>
|
||||||
|
<h1>title 2</h1>
|
||||||
|
`);
|
||||||
|
const error = await expect(page.locator('body')).toMatchAriaSnapshot(`
|
||||||
|
- heading "title" [level=1]
|
||||||
|
- heading "title 2" [level=1]
|
||||||
|
`, { timeout: 1000 }).catch(e => e);
|
||||||
|
expect(stripAnsi(error.message)).toContain(`
|
||||||
|
- heading "title" [level=1]
|
||||||
|
- heading "title 2" [level=1]`);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue