diff --git a/crates/fspy/tests/node_fs.rs b/crates/fspy/tests/node_fs.rs index f1563663..6534fdaa 100644 --- a/crates/fspy/tests/node_fs.rs +++ b/crates/fspy/tests/node_fs.rs @@ -1,6 +1,9 @@ mod test_utils; -use std::env::{current_dir, vars_os}; +use std::{ + env::{current_dir, vars_os}, + path::Path, +}; use fspy::{AccessMode, PathAccessIterable}; use test_utils::assert_contains; @@ -24,6 +27,22 @@ async fn read_sync() -> anyhow::Result<()> { Ok(()) } +#[tokio::test] +async fn write_sync() -> anyhow::Result<()> { + let path = Path::new(env!("CARGO_TARGET_TMPDIR")).join("hello.json"); + println!("path: {path:?}"); + let accesses = track_node_script(&format!( + "try {{ fs.writeFileSync('{}', 'world') }} catch {{}}", + path.display() + )) + .await?; + for access in accesses.iter() { + println!("access: {access:?}"); + } + assert_contains(&accesses, &path, AccessMode::Write); + Ok(()) +} + #[tokio::test] async fn read_dir_sync() -> anyhow::Result<()> { let accesses = track_node_script("try { fs.readdirSync('.') } catch {}").await?;