You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
There is a known limitation in both this addon and jest-image-snapshots: running jest -u won't delete obsolete screenshots.
This is due to fact, that there is no source of information for runner about which screenshots must be used.
One possible solution would be to create such source in form of json file which would be placed in snapshotsDir (default or specified by user). The scturcure of this file would be:
The rest of the logic could be taken from original toMatchSnapshot().
I propose to use testName => {filePath, meta} instead of testName => filePath, so one could store and read additional info in custom matchers by calling:
import {getMetaFor} from 'jest-screenshots';
...
const myMeta = getMetaFor(this);
...
exprect(target).toMatchImageSnapshot({
meta?: {...} // any serializable data
})
Our particular use case is to store enzyme's .html() in meta and compare it with target.html() before taking actual screenshot for comparison. For now we keep all that logic in our custom matcher and it saves plenty of time for non-changed assertions (no need to wait for puppeteer). Another use case could be storing settings (antialiasing/threshholds) or environment (os/browser) used to take screenshot.
It may seem over-complicated at first glance, but actual implementation details would be hidden for most users while other could benefit from it.
If this feature is anticipated I can make a PR.
The text was updated successfully, but these errors were encountered:
Hi!
There is a known limitation in both this addon and jest-image-snapshots: running
jest -u
won't delete obsolete screenshots.This is due to fact, that there is no source of information for runner about which screenshots must be used.
One possible solution would be to create such source in form of json file which would be placed in
snapshotsDir
(default or specified by user). The scturcure of this file would be:The rest of the logic could be taken from original
toMatchSnapshot()
.I propose to use
testName => {filePath, meta}
instead oftestName => filePath
, so one could store and read additional info in custom matchers by calling:Our particular use case is to store enzyme's
.html()
in meta and compare it withtarget.html()
before taking actual screenshot for comparison. For now we keep all that logic in our custom matcher and it saves plenty of time for non-changed assertions (no need to wait for puppeteer). Another use case could be storing settings (antialiasing/threshholds) or environment (os/browser) used to take screenshot.It may seem over-complicated at first glance, but actual implementation details would be hidden for most users while other could benefit from it.
If this feature is anticipated I can make a PR.
The text was updated successfully, but these errors were encountered: