Add WASM unit tests with browser execution#195
Conversation
9b879db to
006e78e
Compare
| - name: Run WASM tests in headless browser | ||
| run: | | ||
| cd whoami | ||
| wasm-pack test --headless --chrome --all-features |
There was a problem hiding this comment.
Would it be possible to use wasmtime instead?
|
@naoNao89 Thanks for the PR! I think a number of changes will be needed before merging, but it's pretty cool as-is. I think mostly it seems like the platform specific code wouldn't be compiled when running the wasm tests since it's gated on |
- Add 20 WASM integration tests running in headless Chrome - Add 10 native Unix error handling tests with mock FFI - Add Windows error handling test infrastructure - Add CI job for automated WASM testing - Add wasm-bindgen-test dev dependency
006e78e to
f38d13d
Compare
|
Done, removed the redundant console dep and dead test code. Added a big TODO about potentially switching to wasmtime instead of Chrome for CI. Would eliminate browser dependencies and speed up tests, worth discussing for a future PR. |
|
@naoNao89 I'm still not quite sure how this PR all comes together. As far as I can tell My eventual vision, (that I didn't fully write out) should contain something like this: {
mock_set_pass_wd(PassWd { .. });
mock_set_getpwuid_r(Ok(()));
let res = whoami::username();
assert!(res, Ok("mock_username"));
mock_set_errno(EIO);
mock_set_getpwuid_r(Err(()));
let res = whoami::username();
assert!(res, Err(..));
}I think for a next step, if you could split part of this (probably targeting a specific platform to wasm) into a smaller PR, that would be really helpful for me. Thank you! |
Implements WebAssembly unit tests as requested in #73. Adds 20 WASM browser tests running in headless Chrome, 10 native error handling tests with mock FFI, and CI automation.
fixes #73