Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ivangabriele/jrest
The equivalent of Jest for Rust.
https://github.com/ivangabriele/jrest
jest rust test test-framework testing unit unit-test unit-testing unittest
Last synced: 14 days ago
JSON representation
The equivalent of Jest for Rust.
- Host: GitHub
- URL: https://github.com/ivangabriele/jrest
- Owner: ivangabriele
- License: mit
- Created: 2023-06-26T20:33:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-25T22:57:24.000Z (11 months ago)
- Last Synced: 2024-05-01T14:06:48.316Z (10 months ago)
- Topics: jest, rust, test, test-framework, testing, unit, unit-test, unit-testing, unittest
- Language: Rust
- Homepage:
- Size: 62.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jrest
[](https://crates.io/crates/jrest)
[](https://docs.rs/jrest/latest/jrest)
[](https://github.com/ivangabriele/jrest/actions?query=branch%3Amain+workflow%3ATest++)
[](https://app.codecov.io/github/ivangabriele/jrest)The equivalent of [Jest](https://jestjs.io) for Rust.
**Jrest** is a testing framework project for Rust, inspired by [Jest](https://jestjs.io),
easy to write and easy to read, with fancy diffs when tests fail.> ⚠️ Be aware that this is a work in progress.
But it should get regular updates since I'm using it every week on my own open-source projects.---
- [Installation](#installation)
- [Usage](#usage)
- [`.to_be()`](#to_be)
- [Primitives](#primitives)
- [`.to_be_greater_than()`](#to_be_greater_than)
- [`.to_be_greater_than_or_equal()`](#to_be_greater_than_or_equal)
- [`.to_be_less_than()`](#to_be_less_than)
- [`.to_be_less_than_or_equal()`](#to_be_less_than_or_equal)
- [Strings](#strings)
- [`.to_start_with()`](#to_start_with)
- [`.to_start_with()`](#to_start_with-1)
- [Roadmap](#roadmap)
- [Thanks](#thanks)---
## Installation
```sh
cargo add --dev jrest
```## Usage
### `.to_be()`
```rust
#[cfg(test)]
mod tests {
use jrest::expect;#[test]
fn test_something() {
expect!("A &str").to_be("A &str");
expect!("A String".to_string()).to_be("A String".to_string());
}
}
```### Primitives
#### `.to_be_greater_than()`
```rust
#[cfg(test)]
mod tests {
use jrest::expect;#[test]
fn test_something() {
expect!(3).to_be_greater_than(2);
}
}
```#### `.to_be_greater_than_or_equal()`
```rust
#[cfg(test)]
mod tests {
use jrest::expect;#[test]
fn test_something() {
expect!(3).to_be_greater_than_or_equal(2);
expect!(3).to_be_greater_than_or_equal(3);
}
}
```#### `.to_be_less_than()`
```rust
#[cfg(test)]
mod tests {
use jrest::expect;#[test]
fn test_something() {
expect!(2).to_be_less_than(3);
}
}
```#### `.to_be_less_than_or_equal()`
```rust
#[cfg(test)]
mod tests {
use jrest::expect;#[test]
fn test_something() {
expect!(2).to_be_less_than_or_equal(3);
expect!(2).to_be_less_than_or_equal(2);
}
}
```### Strings
#### `.to_start_with()`
```rust
#[cfg(test)]
mod tests {
use jrest::expect;#[test]
fn test_something() {
expect!("cargo").to_end_with("go");
}
}
```#### `.to_start_with()`
```rust
#[cfg(test)]
mod tests {
use jrest::expect;#[test]
fn test_something() {
expect!("cargo").to_start_with("car");
}
}
```## Roadmap
- [ ] `.toContain()`
- [ ] `.toHaveLength()`
- [ ] `.toMatch()`
- [ ] `.toMatchObject()`
- [ ] `.toThrow()`## Thanks
- [Tom Pridham](https://github.com/TomPridham)
for [test-env-helpers](https://github.com/TomPridham/test-env-helpers) inspiration.