Contributing
Formatting
All Rust and JS/TS code must be formatted to pass our CI tests.
- Format Rust:
cargo fmt
- Format JS/TS:
yarn run prettier --write **/*.ts
We plan to add a Markdown formatter requirement.
Tests
There are 2 types of tests available. The browser test suite is more extensive, but currently requires manual run. And the Jest tests that check the subset of Zaplib functionality using NodeJS environment.
Browser tests
- Build the test suite:
cargo zaplib build -p test_suite
- Have local server running:
cargo zaplib serve
-
Navigate to http://localhost:3000/zaplib/web/test_suite/
-
Click
Run All Tests
Browser tests (Zapium)
- Install CEF (macOS Intel onl):
cargo zaplib install-deps --devel
- Run the tests:
cargo run -p test_suite
- Click
Run All Tests
Browser tests via chromedriver (similar to CI):
- Install ChromeDriver:
brew install --cask chromedriver
- Run chromedriver:
chromedriver
- Build the examples:
zaplib/scripts/build_website_dev.sh
cargo zaplib build --workspace
cargo zaplib build --workspace --release
- Run the CI tests:
cargo run -p zaplib_ci -- --webdriver-url http://localhost:9515
Jest tests
- Build Zaplib:
cd zaplib/web
yarn run watch
- Run the tests:
cd zaplib/web
yarn run jest --detectOpenHandles
Note: if Jest detects open handles, it may be due to unclosed Web Workers. Ensure that zaplib.close()
is called after each test.
Updating the documentation
The documentation files are located at zaplib/docs/src
. To server the docs locally:
- Build the website and watch for changes:
zaplib/scripts/watch_website_dev.sh
- Run local server:
cargo zaplib serve website_dev/ --port 4848
To update the prod website:
- Run:
zaplib/scripts/build_website_prod.sh
- Clone zaplib-site locally:
git clone https://github.com/janpaul123/zaplib-site.git
- Copy the built website files file to zaplib-site:
cp -r website/* ../zaplib-site/
Building the NPM Package
- Install Node & NPM & yarn
- Build the package:
cd zaplib/web && yarn && yarn watch