Improve test docs

master
Chinedu Francis Nwafili 6 years ago
parent 4c4272c002
commit f54de0a067
No known key found for this signature in database
GPG Key ID: 3C85D8F6538D8AD9
  1. 35
      docs/src/commands/test.md

@ -47,10 +47,39 @@ supported in wasm-pack.
To use them you should add standalone `--` argument at the very To use them you should add standalone `--` argument at the very
end of your command, and all the arguments you want to pass to cargo should go after. end of your command, and all the arguments you want to pass to cargo should go after.
Here's an example of running only tests that contain the world "apple". `cargo test -h` for a list of all options that you can pass through.
## Running only some tests
Are your test suite grows it may become unrealistic to need to run all of your tests in a browser when you're
really only debugging one or a few of them.
Here are a few examples of how to run a subset of your tests.
``` ```
wasm-pack test --firefox --headless -- --manifest-path=crates/my-workspace-crate/Cargo.toml apple # Example directory structure
$ tree crates/foo
├── Cargo.toml
├── README.md
├── src
   ├── diff
     ├── diff_test_case.rs
     └── mod.rs
   ├── lib.rs
└── tests
├── diff_patch.rs
``` ```
`cargo test -h` for a list of all options that you can pass through. ```
# Run all tests in tests/diff_patch.rs
wasm-pack test crates/foo --firefox --headless -- --tests diff_patch
# Run all tests in tests/diff_patch.rs that contain the word "replace"
wasm-pack test crates/foo --firefox --headless -- --tests diff_patch replace
# Run all tests inside of a `tests` module inside of src/lib/diff.rs
wasm-pack test crates/foo --firefox --headless -- --lib diff::tests
# Same as the above, but only if they contain the word replace
wasm-pack test crates/foo --firefox --headless -- --lib diff::tests::replace
```

Loading…
Cancel
Save