jestjs/jest

[Feature]: Upstream jest-file-snapshot?

Open

#12734 opened on Apr 25, 2022

View on GitHub
 (13 comments) (2 reactions) (0 assignees)TypeScript (45,361 stars) (6,653 forks)batch import
:rocket: Feature RequestHelp WantedPinned

Description

🚀 Feature Proposal

https://www.npmjs.com/package/jest-file-snapshot

I tend to migrate my snapshots from inline to jest-file-snapshots in almost every project I write tests for (either once the snapshots become unreasonably sized for inline or there's too many).

Do others have feelings about whether this library might be worth thinking about migrating into Jest itself?

Motivation

It's not offensive for me to add:

import { toMatchFile } from 'jest-file-snapshot';
 
expect.extend({ toMatchFile });

Per each file to use the plugin/types, but it is friction. As is ensuring that the generated files do not trigger the watcher, if the matchers were upstreamed Jest can know to watchlist ignore them.

Example

N/A

Pitch

It's ~150 LOC, so probably not a big maintenance burden and does a good job of expanding the scope of how folks can use snapshots

/cc @satya164

Contributor guide