mitsuhiko / insta

A snapshot testing library for rust
https://insta.rs
Apache License 2.0
2.14k stars 95 forks source link

Supporting wasm-bindgen-test? #120

Open anp opened 4 years ago

anp commented 4 years ago

AFAICT the main obstacles to supporting code running in a wasm-bindgen-test context relate to loading information about the project workspace and the snapshot files themselves. Anything else?

The main approaches to loading that data that come to mind for me right now:

  1. have a version of the macros which (somehow?) make use of include_str! -- this would be more tedious to set up but understandable given environment constraints
  2. some way of cooperating with wasm-bindgen-cli to load the files from the parent filesystem
  3. ???

I'm curious if it's something the authors have thought about, and if so what other directions seem promising.

mitsuhiko commented 4 years ago

I haven't investigate this at all yet. insta really could benefit from a few utilities provided by either rusttest or the language itself so I wouldn't be surprised we run into more of those. For instance another thing is that we're using the thread name to find the test name which is known to be an issue (https://github.com/rust-lang/rust/issues/70492). Likewise we don't have a reliable way to get the cargo workspace root (https://github.com/rust-lang/cargo/issues/3946).

Both of those things are likely what you will encounter in a more painful form in your wasm environment.