Using JSError in local Rust tests? #3572
Replies: 2 comments 3 replies
-
|
I'm not entirely sure how this could be actionable by How did you end up exactly in this situation? I'm surprised you are using a |
Beta Was this translation helpful? Give feedback.
-
|
An approach I am using is to use Result<Foo, String> internally in Rust, and then to only convert the String to a JsError in the API functions in between WASM and JavaScript. This way allows more things to be tested with native builds and unit tests. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm new to this wasm ecosystem so apologies if this is a silly issue/question.
I'm trying to test my wasm module inside the Rust project, the same way I would do with a normal Rust crate. I'm running into an issue where I can't pass errors outside of the wasm functions that are compatible with my local architecture. For example:
If this method returns an error, it will panic my tests with:
After tracing through the code, I discovered this is originating in the
JsError::new()call. You cannot instantiate aJSErroroutside of a wasm architecture.Is there a way to get around this so I can pass helpful errors back in my test code?
One solution is to dynamically compile in a different error. For example:
But this seems like a lot of headache for what I have to think is a very common problem? Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions