-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add snapshot testing to contribution guide #7882
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,35 @@ cargo run python install | |
|
||
The storage directory can be configured with `UV_PYTHON_INSTALL_DIR`. | ||
|
||
### Snapshot testing | ||
|
||
uv uses [insta](https://insta.rs/) for snapshot testing. It's recommended (but not necessary) to use | ||
`cargo-insta` for a better snapshot review experience: | ||
|
||
```shell | ||
# Unix | ||
curl -LsSf https://insta.rs/install.sh | sh | ||
|
||
# Windows | ||
powershell -c "irm https://insta.rs/install.ps1 | iex" | ||
``` | ||
|
||
In tests, you can use `uv_snapshot!` to simplify creating snapshots for uv commands. For example: | ||
|
||
```rust | ||
#[test] | ||
fn test_add() { | ||
let context = TestContext::new("3.12"); | ||
uv_snapshot!(context.filters(), context.add().arg("pip"), @r""); | ||
} | ||
``` | ||
|
||
To run and review a specific snapshot test: | ||
|
||
```shell | ||
cargo insta test --review --package <package> --test <test> -- <test_name> -- --exact | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually only use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do use it with
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm mildly in favor of not suggesting it here (and just encouraging There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine with me. |
||
``` | ||
|
||
### Local testing | ||
|
||
You can invoke your development version of uv with `cargo run -- <args>`. For example: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would personally install this through
cargo install cargo-insta
. I'm curious to hear from others on the team.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I would as well