vitest-dev / vitest-dev/vitest
BrowserMode: browser.expect.toMatchScreenshot.beforeComparsion hook
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Clear and concise description of the problem
Sometimes you need to make some transformations with images in screenshot tests before comparison.
Now you have only one way - write custom comparator func, but it is difficult way
Suggested solution
allow describe the hook, what called always before image comparator runs
export default defineConfig({
test: {
browser: {
expect: {
toMatchScreenshot: {
beforeComparsion: async (pathToReference: string, pathToActual: string): Promise<void> => {...},
comparators: {
...
},
},
},
},
},
})
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the browser expect.toMatchScreenshot implementation and its comparator configuration entry point described in the issue. Trace how reference and actual image paths reach the comparator, then verify that the proposed beforeComparsion hook runs before comparison and that existing comparator behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100