veilid/veilid-tools/tests/web.rs

54 lines
1.3 KiB
Rust
Raw Normal View History

2022-11-27 09:00:20 -05:00
//! Test suite for the Web and headless browsers.
#![cfg(target_arch = "wasm32")]
2023-07-02 17:23:04 -04:00
use cfg_if::*;
use parking_lot::Once;
2022-11-27 22:33:41 -05:00
use veilid_tools::tests::*;
2022-11-29 19:22:33 -05:00
2022-11-27 09:00:20 -05:00
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
extern crate wee_alloc;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
static SETUP_ONCE: Once = Once::new();
pub fn setup() -> () {
SETUP_ONCE.call_once(|| {
console_error_panic_hook::set_once();
2022-11-27 10:52:07 -05:00
cfg_if! {
if #[cfg(feature = "tracing")] {
let mut builder = tracing_wasm::WASMLayerConfigBuilder::new();
builder.set_report_logs_in_timings(false);
builder.set_max_level(Level::TRACE);
2023-10-22 21:48:25 -04:00
builder.set_console_config(tracing_wasm::ConsoleConfig::ReportWithoutConsoleColor);
2022-11-27 10:52:07 -05:00
tracing_wasm::set_as_global_default_with_config(builder.build());
2022-11-29 12:16:28 -05:00
} else {
wasm_logger::init(wasm_logger::Config::default());
2022-11-27 10:52:07 -05:00
}
}
2022-11-27 09:00:20 -05:00
});
}
#[wasm_bindgen_test]
async fn run_test_host_interface() {
setup();
test_host_interface::test_all().await;
}
#[wasm_bindgen_test]
async fn run_test_async_tag_lock() {
setup();
test_async_tag_lock::test_all().await;
}
2024-07-19 13:00:15 -04:00
#[wasm_bindgen_test]
async fn run_test_startup_lock() {
setup();
test_startup_lock::test_all().await;
}