@@ -12,8 +12,9 @@ Repository.
12
12
- [ Environment Setup] ( #environment-setup )
13
13
* [ Latest Rust] ( #latest-rust )
14
14
* [ Formatting] ( #formatting )
15
- * [ WASM Build] ( #wasm-build )
16
- * [ WASM in JS] ( #wasm-in-js )
15
+ * [ Testing] ( #testing )
16
+ * [ Wasm Build] ( #wasm-build )
17
+ * [ Wasm in JS] ( #wasm-in-js )
17
18
18
19
- [ Code of Conduct] ( #code-of-conduct )
19
20
@@ -60,8 +61,20 @@ augroup END
60
61
[ vscode] ( https://github.com/rust-lang-nursery/rls-vscode ) . You can just add
61
62
this plugin to your VSCode setup, and magic :sparkles : , everything works!
62
63
63
- ### WASM Build
64
- To be able to use this module in JavaScript and Node, we compile it to WASM. For
64
+ ### Testing
65
+ Rust's in-file tests can be ran with cargo. If print statements are required,
66
+ ` -- --nocapture ` can be passed in as an option as well.
67
+ ```
68
+ cargo test
69
+ ```
70
+
71
+ Tests in ` ./tests ` directory are Wasm tests, and can be ran with:
72
+ ```
73
+ wasm-pack test --node
74
+ ```
75
+
76
+ ### Wasm Build
77
+ To be able to use this module in JavaScript and Node, we compile it to Wasm. For
65
78
that we use [ wasm-bindgen] ( https://github.com/rustwasm/wasm-bindgen ) inside our
66
79
` lib.rs ` , and [ wasm-pack] ( https://github.com/rustwasm/wasm-pack ) to make a
67
80
package to be published to ` npm ` . To do so, install ` wasm-pack ` :
@@ -97,15 +110,15 @@ wasm-pack publish --access=public
97
110
```
98
111
99
112
As you are developing sometimes it's useful to know whether you can compile
100
- to WASM . Especially when you add a new crate to the setup:
113
+ to Wasm . Especially when you add a new crate to the setup:
101
114
``` bash
102
115
cargo check --target wasm32-unknown-unknown
103
116
```
104
117
105
118
Travis CI will also run a wasm-pack build to check we are able to compile this correctly.
106
119
107
- ### WASM in JS
108
- The easiest way to run WASM in the browser is via
120
+ ### Wasm in JS
121
+ The easiest way to run Wasm in the browser is via
109
122
[ webpack] ( https://webpack.js.org/ ) . If you are running this in electron, it's
110
123
recommended to be on webpack > ` 4.29.6 ` . There have been a few bugs that were
111
124
fixed in that version, and we find it to be quite stable. If you're in the
@@ -116,7 +129,7 @@ You will need to add `.wasm` to your [resolve extensions](https://webpack.js.org
116
129
extensions: [' .js' , ' .jsx' , ' .json' , ' less' , ' .wasm' ]
117
130
```
118
131
119
- WASM _ needs_ to be loaded async and dynamically. The easiest way to do this
132
+ Wasm _ needs_ to be loaded async and dynamically. The easiest way to do this
120
133
is to have a [ babel
121
134
plugin] ( https://www.npmjs.com/package/babel-plugin-syntax-dynamic-import ) :
122
135
``` js
0 commit comments