Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(html reporter): fix too much strikethrough in diffs (#11115)
Ross Wollmandadb5cbc30ca
diff --git a/packages/playwright-test/src/matchers/golden.ts b/packages/playwright-test/src/matchers/golden.tsindex d88f7dcc2f..ca499fe5a4 100644--- a/packages/playwright-test/src/matchers/golden.ts+++ b/packages/playwright-test/src/matchers/golden.ts@@ -228,7 +228,7 @@ function diff_prettyTerminal(diffs: diff_match_patch.Diff[]) {html[x] = colors.green(text);break;case DIFF_DELETE:- html[x] = colors.strikethrough(colors.red(text));+ html[x] = colors.reset(colors.strikethrough(colors.red(text)));break;case DIFF_EQUAL:html[x] = text;diff --git a/tests/playwright-test/golden.spec.ts b/tests/playwright-test/golden.spec.tsindex 1d156d060e..c1800bade0 100644--- a/tests/playwright-test/golden.spec.ts+++ b/tests/playwright-test/golden.spec.ts@@ -72,7 +72,7 @@ Line7`,expect(result.exitCode).toBe(1);expect(result.output).toContain('Line1');expect(result.output).toContain('Line2' + colors.green('2'));- expect(result.output).toContain('line' + colors.strikethrough(colors.red('1')) + colors.green('2'));+ expect(result.output).toContain('line' + colors.reset(colors.strikethrough(colors.red('1'))) + colors.green('2'));expect(result.output).toContain('Line3');expect(result.output).toContain('Line5');expect(result.output).toContain('Line7');diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.tsindex ed9d677d5e..6bf898ec4b 100644--- a/tests/playwright-test/reporter-html.spec.ts+++ b/tests/playwright-test/reporter-html.spec.ts@@ -374,3 +374,53 @@ test('should render text attachments as text', async ({ runInlineTest, page, shoawait page.click('text=example-utf16.txt');await expect(page.locator('.attachment-link')).toHaveText(['foo', '{"foo":1}', 'utf16 encoded']);});++test('should strikethough textual diff', async ({ runInlineTest, showReport, page }) => {+ const result = await runInlineTest({+ 'helper.ts': `+ export const test = pwt.test.extend({+ auto: [ async ({}, run, testInfo) => {+ testInfo.snapshotSuffix = '';+ await run();+ }, { auto: true } ]+ });+ `,+ 'a.spec.js-snapshots/snapshot.txt': `old`,+ 'a.spec.js': `+ const { test } = require('./helper');+ test('is a test', ({}) => {+ expect('new').toMatchSnapshot('snapshot.txt');+ });+ `+ }, { reporter: 'dot,html' });+ expect(result.exitCode).toBe(1);+ await showReport();+ await page.click('text="is a test"');+ const stricken = await page.locator('css=strike').innerText();+ expect(stricken).toBe('old');+});++test('should strikethough textual diff with commonalities', async ({ runInlineTest, showReport, page }) => {+ const result = await runInlineTest({+ 'helper.ts': `+ export const test = pwt.test.extend({+ auto: [ async ({}, run, testInfo) => {+ testInfo.snapshotSuffix = '';+ await run();+ }, { auto: true } ]+ });+ `,+ 'a.spec.js-snapshots/snapshot.txt': `oldcommon`,+ 'a.spec.js': `+ const { test } = require('./helper');+ test('is a test', ({}) => {+ expect('newcommon').toMatchSnapshot('snapshot.txt');+ });+ `+ }, { reporter: 'dot,html' });+ expect(result.exitCode).toBe(1);+ await showReport();+ await page.click('text="is a test"');+ const stricken = await page.locator('css=strike').innerText();+ expect(stricken).toBe('old');+});