Skip to main content

snapshot_path

Function snapshot_path 

Source
pub fn snapshot_path(dir: &Path, module_path: &str, name: &str) -> PathBuf
Expand description

The path of the snapshot file for module_path and name under dir.

The file name is <module-path>__<name>.snap, with both components sanitized: :: segment separators in a module path collapse to __, and any other character that is not alphanumeric, _, or - becomes _.

use std::path::{Path, PathBuf};

use test_better_core::TestResult;
use test_better_matchers::{eq, check};
use test_better_snapshot::snapshot_path;

let path = snapshot_path(Path::new("tests/snapshots"), "my_crate::ui", "homepage");
check!(path).satisfies(eq(PathBuf::from("tests/snapshots/my_crate__ui__homepage.snap")))?;