From 500e43931ef67b594409063c5e6d50621cf538de Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 19 Oct 2021 17:38:01 -0700 Subject: [PATCH] test: bring the snapshotter test back (#9635) --- tests/snapshotter.spec.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/snapshotter.spec.ts b/tests/snapshotter.spec.ts index 8807017e6a..89f8094e02 100644 --- a/tests/snapshotter.spec.ts +++ b/tests/snapshotter.spec.ts @@ -153,12 +153,12 @@ it.describe('snapshots', () => { { const handle = await page.$('text=Hello'); const snapshot = await snapshotter.captureSnapshot(toImpl(page), 'snapshot', toImpl(handle)); - expect(distillSnapshot(snapshot)).toBe(''); + expect(distillSnapshot(snapshot, false /* distillTarget */)).toBe(''); } { const handle = await page.$('text=World'); const snapshot = await snapshotter.captureSnapshot(toImpl(page), 'snapshot2', toImpl(handle)); - expect(distillSnapshot(snapshot)).toBe(''); + expect(distillSnapshot(snapshot, false /* distillTarget */)).toBe(''); } }); @@ -182,8 +182,10 @@ it.describe('snapshots', () => { }); }); -function distillSnapshot(snapshot) { - const { html } = snapshot.render(); +function distillSnapshot(snapshot, distillTarget = true) { + let { html } = snapshot.render(); + if (distillTarget) + html = html.replace(/\s__playwright_target__="[^"]+"/g, ''); return html .replace(/