feat: add path option to toMatchSnapshot#9156
Conversation
adds optional path to toMathchSnapshot assertion.
dgozman
left a comment
There was a problem hiding this comment.
Thank you for the PR! See comments inline.
|
@dgozman I'm curious what your thoughts are on adding a // playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
snapshotDir: 'snapshots',
};
export default config;Would there be any issue with this? I have started on these changes but think I'll put them in a follow up PR to this one. |
dgozman
left a comment
There was a problem hiding this comment.
I am sorry that this PR turns into a lot of work, but it is going to be a great feature!
All good! Thanks for the quick review. I agree with all your comments, I'll address them tomorrow. 👍🏼 |
|
I wasn't sure about the naming in the docs for |
dgozman
left a comment
There was a problem hiding this comment.
I think this works nicely, just a few code comments.
BTW do I need to manually update docs/src/test-api/class-testinfo.md and docs/src/test-snapshots-js.md from types/test.d.ts or is there some auto generation script I am missing?
Files in docs/src are the source of truth, types/test.d.ts is generated from them by npm run watch.
I wasn't sure about the naming in the docs for toMatchSnapshot and changing it from snapshotName to pathSegments. Might be best to keep it as is with snapshotName with the note about using it as pathSegments
I agree that it's better to keep snapshotName.
Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
dgozman
left a comment
There was a problem hiding this comment.
Apart from the spread and some failing tests, this looks perfect!
dgozman
left a comment
There was a problem hiding this comment.
Two suggestions to fix failing tests, the rest is great!
Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
…tionWithBaseChange * upstream/master: chore: roll Electron to 12.2.1 (microsoft#9271) test: use separate Playwright instance to automate inspector (microsoft#9270) feat(inspector): use chrome/msedge when chromium is not available (microsoft#9269) fix(webkit): deduce response mime type from content-type (microsoft#9264) fix(fetch): use data, form and multipart for different post data (microsoft#9248) chore: split ContextRecorder from inspector (microsoft#9250) feat: add path option to `toMatchSnapshot` (microsoft#9156) feat(cli): Support trace file URLs (microsoft#9030) browser(webkit): roll to 23/09/21 (microsoft#9107) feat(chromium): roll to r926934 (microsoft#9259) browser(chromium): roll to r926934 (microsoft#9255) test: fix 'should fulfill with fetch result and overrides' test (microsoft#9252) feat(test-runner): add reuse context mode to share a single context between tests (microsoft#9115) fix(docs): test-runner location column type (microsoft#9222)
allow
snapshotNameto accept an array of path segments intoMathchSnapshot.This would set and lookup the screenshot from
example.spec.ts-snapshots/test/path/landing-<suffix>.png.The current functionality of
snapshotNameas a'string'is preserved. This string will continue to be sanitized for file path as is currently done.This would set and lookup the screenshot from
example.spec.ts-snapshots/test-path-landing-<suffix>.png.Related to #7792