-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
guide: Add documentation for testing with wasm-bindgen-test
#818
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
Conversation
Add this to the root of your test crate, e.g. `$MY_CRATE/tests/wasm.rs`: | ||
|
||
```rust | ||
wasm_bindgen_test_configure!(run_in_browser); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may want to use use wasm_bindgen_test::wasm_bindgen_test_configure;
just above it (to bring the macro into scope)
| | ||
curl --retry 5 -LO https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip | ||
unzip chromedriver_linux64.zip | ||
export CHROMEDRIVER_ARGS=--verbose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this shouldn't be required
| | ||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash | ||
source ~/.nvm/nvm.sh | ||
nvm install v10.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this isn't necessarily required actually, the version of node
installed automatically on Travis should already have wasm support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node comes with travis, even for non-node/js projects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so! I could be wrong though, I'd have to check...
curl --retry 5 -LO https://github.com/mozilla/geckodriver/releases/download/v0.21.0/geckodriver-v0.21.0-linux64.tar.gz | ||
tar xf geckodriver-v0.21.0-linux64.tar.gz | ||
|
||
INSTALL_CHROMEDRIVER: &INSTALL_CHROMEDRIVER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using this yaml syntax it may be best to inline it directly into the install
section below to avoid confusing those who don't know about the syntax (which is probably almost everyone)
``` | ||
|
||
Writing tests is the same as normal Rust `#[test]`s, except we are using the | ||
`#[wasm_bindgen_test]` attribute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a good spot to mention pub mod ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have left all those comments as part of a review...
3b73132
to
e2e815a
Compare
|
||
install: | ||
- rustup target add wasm32-unknown-unknown | ||
- cargo install wasm-bindgen-cli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd imagine that a bunch of people will just copy this so ideally this would be a fast-enough starting point.
This can take minutes, so could it make sense to instead either:
option 1. Download / decompress a release binary and move it to either ~/.cargo/bin
or /usr/local/bin
option 2. Cache cargo deps (I see that the wasm-bindgen
repo's travis seems to do this?)
Happy to do either if you think it makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chinedufn totally -- good call! I think option 1 is more straight forward, and we could also have a comment mentioning something like
Download and unpack the
wasm-bindgen
CLI tools. Alternatively, usewasm-pack
to managewasm-bindgen
binaries for you.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the guidance!
For posterity #824
Fixes #616