This example demonstrates how to write and run tests for Swift code compiled to WebAssembly using JavaScriptKit.
To run the tests, use the following command:
swift package --disable-sandbox --swift-sdk wasm32-unknown-wasi js test
To generate and view code coverage reports:
- Run tests with code coverage enabled:
swift package --disable-sandbox --swift-sdk wasm32-unknown-wasi js test --enable-code-coverage
- Generate HTML coverage report:
llvm-cov show -instr-profile=.build/plugins/PackageToJS/outputs/PackageTests/default.profdata --format=html .build/plugins/PackageToJS/outputs/PackageTests/main.wasm -o .build/coverage/html Sources
- Serve and view the coverage report:
npx serve .build/coverage/html