| Repository | Link |
|---|---|
rs-jest | https://github.com/DrSensor/rs-jest |
| Example | https://github.com/DrSensor/example-stencil-rust |
rs-jest is a Jest preprocessor for transforming Rust code so that Jest can test a project that incorporate Rust on it.
Well, the feature are same as rollup-plugin-rust.
The technology stack are pretty much the same as rollup-plugin-rust (see this post) with the difference in CI workflow and the linter + static-type-checker that I use.
Unlike rollup-plugin-rust, there is no main dependencies for this project. I actually want to make rust-native-wasm-loader as the main dependencies just like rollup-plugin-rust but I can't do that because Jest only support synchronous transformation and doesn't have intention to support asynchronous transformation. This is why I rewrote some functions of cargo.js in rust-native-wasm-loader to became synchronous one (see cargo.ts file).
The CI workflow with the build tools itself are almost the same as rollup-plugin-rust with the exception that I don't need to move smoke-test for stencil into TravisCI 😆.
Since I had bad experience with Flow because it keep eating my RAM unpolitely 😂, I use Typescript as replacement. Typescript has their own linter called TSLint which mean I don't need ESLint that I setup in rollup-plugin-rust.
The test framework I used for this project is of course Jest running on Nodejs v8 or higher. The reason the minimum Nodejs is not v6 because the WebAssembly support begins in Nodejs v8. For the approach, I implement 2 kinds of test: unit-tests and smoke-tests. The unit-tests use Jest which automatically confirms that the generated code can be run in Nodejs ≥8.x. The smoke-tests itself written as example-stencil-rust (linked as git submodule) which automatically confirm that it can be used in the real project. There is weird setup for the unit-tests itself because I want to test the edge case just like how ts-jest approach it. I rely the test-cases pretty much on the fixtures which cause the number the test cases are pretty minimum. At this moment the test-cases are only one but it testing 6 fixtures 🤔.
To make maintaining rollup-plugin-rust and rs-jest easier and both of them are compatible within each release, I plan to add additional library as shown below:
webassembly-loader.cargo-cli-wrapper was released and see if he also want to maintain or use it.Just DM's me, make a Github issue or writes a comment below if interested. For guidelines, see Contributing section (contribution is always welcome so don't be afraid to make mistakes 🙂).
Reminder for myself! When you want to place comment of some code refences from Github, use copy permalink instead of copy line. This is what I found in most ts-jest codebase 😂
Parting words: by the way, where can I get
supported by utopian.iobadges 😅