fix link to cargo.toml example in testing

This commit is contained in:
bytedream 2024-01-16 18:10:43 +01:00
parent 96adaf3211
commit 60fb3a9c7a

View File

@ -3,7 +3,7 @@
Testing is not very different from testing any other ordinary Rust crate. Testing is not very different from testing any other ordinary Rust crate.
When running tests, Rust tries to execute the generated Javascript glue directly which will result in an error. When running tests, Rust tries to execute the generated Javascript glue directly which will result in an error.
You have to specify the test runner which executes the Javascript, either in the `.cargo/config.toml` file (described [here]()) or via the `CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER` env variable to `node --experimental-default-type=module`. You have to specify the test runner which executes the Javascript, either in the `.cargo/config.toml` file (described [here](./tutorial/creating-a-project.md#cargoconfigtoml-optional)) or via the `CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER` env variable to `node --experimental-default-type=module`.
<br> <br>
If your crate is a library, you also have to remove the `-o<library name>.js` compiler option as it modifies the output filename which the Rust test suite can't track. If your crate is a library, you also have to remove the `-o<library name>.js` compiler option as it modifies the output filename which the Rust test suite can't track.
Because the `test` subcommand compiles the tests as normal binaries, the Emscripten compiler automatically creates the js glue. Because the `test` subcommand compiles the tests as normal binaries, the Emscripten compiler automatically creates the js glue.