Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit 72fa32c

Browse files
authored
wasm test for failing documents in sales.supplies collection (#33)
1 parent 284f699 commit 72fa32c

File tree

4 files changed

+60
-46
lines changed

4 files changed

+60
-46
lines changed

Diff for: CONTRIBUTING.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ Repository.
1212
- [Environment Setup](#environment-setup)
1313
* [Latest Rust](#latest-rust)
1414
* [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)
1718

1819
- [Code of Conduct](#code-of-conduct)
1920

@@ -60,8 +61,20 @@ augroup END
6061
[vscode](https://github.com/rust-lang-nursery/rls-vscode). You can just add
6162
this plugin to your VSCode setup, and magic :sparkles:, everything works!
6263

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
6578
that we use [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen) inside our
6679
`lib.rs`, and [wasm-pack](https://github.com/rustwasm/wasm-pack) to make a
6780
package to be published to `npm`. To do so, install `wasm-pack`:
@@ -97,15 +110,15 @@ wasm-pack publish --access=public
97110
```
98111

99112
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:
101114
```bash
102115
cargo check --target wasm32-unknown-unknown
103116
```
104117

105118
Travis CI will also run a wasm-pack build to check we are able to compile this correctly.
106119

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
109122
[webpack](https://webpack.js.org/). If you are running this in electron, it's
110123
recommended to be on webpack > `4.29.6`. There have been a few bugs that were
111124
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
116129
extensions: ['.js', '.jsx', '.json', 'less', '.wasm']
117130
```
118131

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
120133
is to have a [babel
121134
plugin](https://www.npmjs.com/package/babel-plugin-syntax-dynamic-import):
122135
```js

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ wee_alloc = "0.4.2"
2222
console_error_panic_hook = "0.1.6"
2323
js-sys = "0.3.25"
2424
web-sys = { version = "0.3.16", features = ['console'] }
25+
wasm-bindgen-test = "0.3.8"
2526

2627
[dependencies.wasm-bindgen]
2728
version = "^0.2.37"

Diff for: src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ use crate::lib_wasm::*;
9292
#[wasm_bindgen]
9393
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
9494
pub struct SchemaParser {
95-
count: usize,
95+
pub count: usize,
9696
fields: HashMap<String, Field>,
9797
}
9898

0 commit comments

Comments
 (0)