Skip to content

Commit

Permalink
[WIP] fix: execute client_wasm tests for nodejs
Browse files Browse the repository at this point in the history
  • Loading branch information
dlachaume committed Jan 8, 2025
1 parent ed0e96f commit 93d9e4f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
- name: Test 'mithril-client-wasm' - NodeJS
shell: bash
run: |
wasm-pack test --node mithril-client-wasm --release
wasm-pack test --node mithril-client-wasm --release --features --test-node
- name: Publish Mithril Distribution (WASM)
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions mithril-client-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mithril-build-script = { path = "../internal/mithril-build-script" }
[features]
# Include nothing by default
default = []
test-node = []

[package.metadata.docs.rs]
all-features = true
Expand Down
16 changes: 14 additions & 2 deletions mithril-client-wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@ all: test build
build:
npm run build

test:
test: test-web test-node

test-web:
pkill -f "mithril-aggregator-fake" || true
${CARGO} run -p mithril-aggregator-fake -- -p 8000 &
if wasm-pack test --headless --firefox --chrome --release; then \
pkill -f "mithril-aggregator-fake" || true; \
else \
pkill -f "mithril-aggregator-fake" || true; \
exit 1; \
fi

test-node:
pkill -f "mithril-aggregator-fake" || true
${CARGO} run -p mithril-aggregator-fake -- -p 8000 &
if wasm-pack test --headless --firefox --chrome --node --release; then \
if wasm-pack test --node --release --features test-node; then \
pkill -f "mithril-aggregator-fake" || true; \
else \
pkill -f "mithril-aggregator-fake" || true; \
Expand Down
2 changes: 2 additions & 0 deletions mithril-client-wasm/src/certificate_verification_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ impl CertificateVerifierCache for LocalStorageCertificateVerifierCache {
}
}

#[cfg(not(feature = "test-node"))]
#[cfg(test)]
pub(crate) mod test_tools {
use std::collections::HashMap;
Expand Down Expand Up @@ -249,6 +250,7 @@ pub(crate) mod test_tools {
}
}

#[cfg(not(feature = "test-node"))]
#[cfg(test)]
mod tests {
use std::collections::HashMap;
Expand Down
1 change: 1 addition & 0 deletions mithril-client-wasm/src/client_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ mod tests {
get_mithril_client(options)
}

#[cfg(not(feature = "test-node"))]
wasm_bindgen_test_configure!(run_in_browser);

#[wasm_bindgen_test]
Expand Down

0 comments on commit 93d9e4f

Please sign in to comment.