mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(rebase): do not apply multiple rebaselines to the same assertion (#33629)
This commit is contained in:
parent
c81504c5d6
commit
77dee44984
@ -83,6 +83,10 @@ export async function applySuggestedRebaselines(config: FullConfigInternal, repo
|
|||||||
const indent = lines[matcher.loc!.start.line - 1].match(/^\s*/)![0];
|
const indent = lines[matcher.loc!.start.line - 1].match(/^\s*/)![0];
|
||||||
const newText = replacement.code.replace(/\{indent\}/g, indent);
|
const newText = replacement.code.replace(/\{indent\}/g, indent);
|
||||||
ranges.push({ start: matcher.start!, end: node.end!, oldText: source.substring(matcher.start!, node.end!), newText });
|
ranges.push({ start: matcher.start!, end: node.end!, oldText: source.substring(matcher.start!, node.end!), newText });
|
||||||
|
// We can have multiple, hopefully equal, replacements for the same location,
|
||||||
|
// for example when a single test runs multiple times because of projects or retries.
|
||||||
|
// Do not apply multiple replacements for the same assertion.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -24,12 +24,15 @@ function trimPatch(patch: string) {
|
|||||||
return patch.split('\n').map(line => line.trimEnd()).join('\n');
|
return patch.split('\n').map(line => line.trimEnd()).join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
test('should update snapshot with the update-snapshots flag', async ({ runInlineTest }, testInfo) => {
|
test('should update snapshot with the update-snapshots flag with multiple projects', async ({ runInlineTest }, testInfo) => {
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
export default { projects: [{ name: 'p1' }, { name: 'p2' }] };
|
||||||
|
`,
|
||||||
'a.spec.ts': `
|
'a.spec.ts': `
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
test('test', async ({ page }) => {
|
test('test', async ({ page }) => {
|
||||||
await page.setContent(\`<h1>hello</h1>\`);
|
await page.setContent(\`<h1>hello</h1><h2>bye</h2>\`);
|
||||||
await expect(page.locator('body')).toMatchAriaSnapshot(\`
|
await expect(page.locator('body')).toMatchAriaSnapshot(\`
|
||||||
- heading "world"
|
- heading "world"
|
||||||
\`);
|
\`);
|
||||||
@ -43,12 +46,13 @@ test('should update snapshot with the update-snapshots flag', async ({ runInline
|
|||||||
expect(trimPatch(data)).toBe(`diff --git a/a.spec.ts b/a.spec.ts
|
expect(trimPatch(data)).toBe(`diff --git a/a.spec.ts b/a.spec.ts
|
||||||
--- a/a.spec.ts
|
--- a/a.spec.ts
|
||||||
+++ b/a.spec.ts
|
+++ b/a.spec.ts
|
||||||
@@ -3,7 +3,7 @@
|
@@ -3,7 +3,8 @@
|
||||||
test('test', async ({ page }) => {
|
test('test', async ({ page }) => {
|
||||||
await page.setContent(\`<h1>hello</h1>\`);
|
await page.setContent(\`<h1>hello</h1><h2>bye</h2>\`);
|
||||||
await expect(page.locator('body')).toMatchAriaSnapshot(\`
|
await expect(page.locator('body')).toMatchAriaSnapshot(\`
|
||||||
- - heading "world"
|
- - heading "world"
|
||||||
+ - heading "hello" [level=1]
|
+ - heading "hello" [level=1]
|
||||||
|
+ - heading "bye" [level=2]
|
||||||
\`);
|
\`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user