From f54de0a06750cfeeb58438cf6a91821d1691030c Mon Sep 17 00:00:00 2001 From: Chinedu Francis Nwafili Date: Tue, 29 Jan 2019 07:26:40 -0500 Subject: [PATCH] Improve test docs --- docs/src/commands/test.md | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/docs/src/commands/test.md b/docs/src/commands/test.md index ec8663f..56b21fd 100644 --- a/docs/src/commands/test.md +++ b/docs/src/commands/test.md @@ -47,10 +47,39 @@ supported in wasm-pack. 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. -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 +```