Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion crates/fspy/tests/node_fs.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image.png

Ok(())
}

#[tokio::test]
async fn read_dir_sync() -> anyhow::Result<()> {
let accesses = track_node_script("try { fs.readdirSync('.') } catch {}").await?;
Expand Down
Loading