- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
How to run actual unit tests on headless browser? #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How about this? #[cfg(test)]
extern crate wasm_bindgen_test;
#[cfg(test)]
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); In a mod: #[cfg(test)]
use wasm_bindgen_test::*;
//....
#[cfg(test)]
#[wasm_bindgen_test]
fn test_on_web() {
let div = document.create_element("div");
assert_eq!(div.tag_name(), "DIV");
assert_eq!(1 + 1, 2);
} I think I successfully run test with this setup! The output is:
|
Wait a minute! I know the problem now. It seems the tests are only runnable if the module itself is visible to |
So, I was in luck because I put it in a pub mod. I think it must be |
Ah yes unfortunately |
I'll close it then as my issue is ironed out. Thank you both. |
Currently, as I have tried, we can only run integration tests with the help of
wasm-bindgen-test-runner
.Is there a way to run such tests from within the module itself?
The text was updated successfully, but these errors were encountered: