Open killercup opened 5 years ago
Good idea. While "golden state" tests are brittle, they can be useful and making it easier to update them would be a big help.
We'll also want to look into this for #33. The main impact of #33 on this issue is ensuring we have good names for both of them.
I'm assuming the snapshots would be kept under revision control.
Options for where to store
tests/fixtures
.predicate::eq_snapshot!().from("tests/fixtures")
) with a default locationNext, what is the snapshot's filename
git rm * && cargo test && git add *
eq_snapshot
would probably want a .utf8()
like eq_file
so we know when can provide more useful failure messages.
Any other API considerations?
See insta for ideas we could pillage https://crates.io/crates/insta
Did we ever talk about snapshot tests? I don't recall, and I didn't find an issue in this or the assert_{cmd,cli} repos.
The idea is this: Instead of manually writing
predicate::path::eq_file(Path::new("some.file")).utf8().unwrap();
, you'd have apredicate::eq_snapshot!()
macro that expands to a uniq filename predicate with the ability to create that file with the content it gets on the first test run or when usingRECORD_SNAPSHOTS=1
or something similar.