jrest

Crates.iojrest
lib.rsjrest
version0.2.3
sourcesrc
created_at2023-06-28 20:19:27.57642
updated_at2023-07-05 11:03:55.663903
descriptionThe equivalent of Jest for Rust.
homepagehttps://github.com/ivangabriele/jrest#readme
repositoryhttps://github.com/ivangabriele/jrest
max_upload_size
id902749
size13,001
Ivan Gabriele (ivangabriele)

documentation

README

Jrest

Crates.io Package Docs.rs Documentation Test Workflow Status Code Coverage

The equivalent of Jest for Rust.

Jrest is a testing framework project for Rust, inspired by Jest, 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

cargo add --dev jrest

Usage

.to_be()

#[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()

#[cfg(test)]
  mod tests {
  use jrest::expect;

  #[test]
  fn test_something() {
      expect!(3).to_be_greater_than(2);
  }
}

.to_be_greater_than_or_equal()

#[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()

#[cfg(test)]
mod tests {
  use jrest::expect;

  #[test]
  fn test_something() {
      expect!(2).to_be_less_than(3);
  }
}

.to_be_less_than_or_equal()

#[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()

#[cfg(test)]
mod tests {
  use jrest::expect;

  #[test]
  fn test_something() {
      expect!("cargo").to_end_with("go");
  }
}

.to_start_with()

#[cfg(test)]
mod tests {
  use jrest::expect;

  #[test]
  fn test_something() {
      expect!("cargo").to_start_with("car");
  }
}

Roadmap

  • .toContain()
  • .toHaveLength()
  • .toMatch()
  • .toMatchObject()
  • .toThrow()

Thanks

Commit count: 41

cargo fmt