From 1e9e002cec9a0e1715209f1fd6b55907493462d6 Mon Sep 17 00:00:00 2001 From: ben little Date: Fri, 19 Jul 2024 11:21:10 -0600 Subject: [PATCH] add browser-test feature --- .github/workflows/tests.yml | 6 +++--- crates/net/Cargo.toml | 2 ++ crates/net/tests/http.rs | 2 +- crates/net/tests/query.rs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8912e382..ee0c204c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -250,7 +250,7 @@ jobs: SSE_ECHO_SERVER_URL: 'http://localhost:8081/.sse' run: | cd crates/net - wasm-pack test --chrome --firefox --headless --all-features + wasm-pack test --chrome --firefox --headless --features=default,io-util,browser-test - uses: dtolnay/rust-toolchain@master with: @@ -262,11 +262,11 @@ jobs: HTTPBIN_URL: 'http://localhost:8080' WS_ECHO_SERVER_URL: 'ws://localhost:8081' SSE_ECHO_SERVER_URL: 'http://localhost:8081/.sse' - run: cargo test -p gloo-net --all-features + run: cargo test -p gloo-net --features=default,io-util - name: Run node tests env: HTTPBIN_URL: 'http://localhost:8080' WS_ECHO_SERVER_URL: 'ws://localhost:8081' SSE_ECHO_SERVER_URL: 'http://localhost:8081/.sse' - run: wasm-pack test --node crates/net --all-features + run: wasm-pack test --node crates/net --features=default,io-util diff --git a/crates/net/Cargo.toml b/crates/net/Cargo.toml index 73681ee5..a0614686 100644 --- a/crates/net/Cargo.toml +++ b/crates/net/Cargo.toml @@ -102,3 +102,5 @@ eventsource = [ ] # As of now, only implements `AsyncRead` and `AsyncWrite` on `WebSocket` io-util = ["futures-io"] +# For test runner only. Enables browser tests. +browser-test = [] diff --git a/crates/net/tests/http.rs b/crates/net/tests/http.rs index c63cb469..38198c79 100644 --- a/crates/net/tests/http.rs +++ b/crates/net/tests/http.rs @@ -3,7 +3,7 @@ use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use wasm_bindgen_test::*; -#[cfg(target_arch = "wasm32-unknown-unknown")] +#[cfg(feature = "browser_test")] wasm_bindgen_test_configure!(run_in_browser); static HTTPBIN_URL: Lazy<&'static str> = diff --git a/crates/net/tests/query.rs b/crates/net/tests/query.rs index c649e446..4492066a 100644 --- a/crates/net/tests/query.rs +++ b/crates/net/tests/query.rs @@ -1,7 +1,7 @@ use gloo_net::http::QueryParams; use wasm_bindgen_test::*; -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "browser_test")] wasm_bindgen_test_configure!(run_in_browser); #[wasm_bindgen_test]