-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposing snapshot manager logic as a library #1768
Comments
The Values are The deserializing-using-plugins problem is surmountable, being one of configuration. The snapshot name extraction problem requires a change to the In light of #1769, do you see this as an entirely separate process or as a complement to an AVA run? In which case we could surface the failing snapshots, you could render in the browser, then rerun a specific test and let AVA update the snapshot. Then we wouldn't need to change the |
It would be really useful to have the name back, otherwise snapshots can very easily get mixed up.
I want it to be able to run in two modes:
Although if I had the "complete" event in #1769, I suppose it could be implemented as: type Data = {
...,
failedSnapshots: Array<{
name: string,
expected: T
actual: U
}>
};
ava.on('complete', (data: Data) => {
browserWs.send(JSON.stringify(data.failedSnapshots));
}); Maybe I could even do it as individual test results come in with a separate event. |
Yes. Roughly, the binary format is:
I think we could add a trailer section:
We wouldn't need to parse this while running tests, but once we've parsed the header it's easy to know where the trailers start. We'd have to bump the snapshot file version number but we could still read v1 snapshots since none of that encoding has changed. Could you elaborate on what kind of values you're snapshotting? Only primitives (except for symbols) can be safely round-tripped through the serialization. Object values are described, so if you're storing |
I was thinking it would do this: t.snapshot(visual(<Comp/>));
// effectively:
t.snapshot({
isVisualSnapshot: true,
value: "<raw><html><string/>..."
}); I'm okay making it just a plain string though |
If we're adding trailers anyway, we could add an "annotation" type trailer: t.snapshot(visual(<Comp/>), {annotations: {visual: true}}) (You'd probably want to wrap that as The nice thing about the |
Description
I'm trying to build some tools on top of Ava's snapshots, but there's a lot of work to read/update them correctly.
I was wondering if Ava could expose some methods for working with snapshots outside of the testing process.
I need two things:
Trying to build a tool that finds all of the React related snapshots and renders stringified HTML into a browser so the visual difference can be compared. If there is no visual difference it can update them all automatically.
The text was updated successfully, but these errors were encountered: