new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · API reference · all subjects

snapshotassertions/methods

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

toMatchSnapshot() method with name parameter

SnapshotAssertions.toMatchSnapshot() method added in v1.22 ensures that a passed value (either a string or Buffer) matches the expected snapshot stored in the test snapshots directory. The method signature is: toMatchSnapshot(name: string | Array<string>, options?: object). The name parameter is required and accepts either a string or an array of strings representing the snapshot name. Options include maxDiffPixels, maxDiffPixelRatio, and threshold for customizing snapshot comparison.

toMatchSnapshot() method without required name parameter

SnapshotAssertions.toMatchSnapshot() method added in v1.22 can be called without a required name parameter. When called this way, the test name and ordinals are used to generate the snapshot name automatically. The method accepts options including maxDiffPixels, maxDiffPixelRatio, name (optional), and threshold. The name option can be a string or array of strings.

toMatchSnapshot() usage example with custom options

Example: expect(await page.screenshot()).toMatchSnapshot('landing-page.png', { maxDiffPixels: 27 }); This allows no more than 27 different pixels when comparing screenshots.

toMatchSnapshot() usage example with threshold option

Example: expect(await page.screenshot()).toMatchSnapshot('landing-page.png', { threshold: 0.3 }); This configures the image matching threshold to 0.3.

toMatchSnapshot() usage example with file path segments

Example: expect(await page.screenshot()).toMatchSnapshot(['landing', 'step2.png']); This brings structure to snapshot files by passing file path segments as an array instead of a flat string.

toMatchSnapshot() usage example without parameters

Example: expect(await page.screenshot()).toMatchSnapshot(); When called without parameters, the file name is derived from the test name automatically.

toMatchSnapshot() usage example with options object

Example: expect(await page.screenshot()).toMatchSnapshot({ name: 'landing-page.png', threshold: 0.3, maxDiffPixels: 27 }); This shows passing options including name, threshold, and maxDiffPixels in a single options object.

Give your agent this brain