Skip to content

Commit c4b1585

Browse files
author
Ari Breitkreuz
committed
Add console_warn and console_error macros
1 parent 12cd9c8 commit c4b1585

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

crates/test/src/rt/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ extern "C" {
233233
#[doc(hidden)]
234234
pub fn js_console_log(s: &str);
235235

236+
#[wasm_bindgen(js_namespace = console, js_name = error)]
237+
#[doc(hidden)]
238+
pub fn js_console_error(s: &str);
239+
240+
#[wasm_bindgen(js_namespace = console, js_name = warn)]
241+
#[doc(hidden)]
242+
pub fn js_console_warn(s: &str);
243+
236244
// General-purpose conversion into a `String`.
237245
#[wasm_bindgen(js_name = String)]
238246
fn stringify(val: &JsValue) -> String;
@@ -243,6 +251,16 @@ pub fn log(args: &fmt::Arguments) {
243251
js_console_log(&args.to_string());
244252
}
245253

254+
/// Internal implementation detail of the `console_warn!` macro.
255+
pub fn log_warn(args: &fmt::Arguments) {
256+
js_console_warn(&args.to_string());
257+
}
258+
259+
/// Internal implementation detail of the `console_error!` macro.
260+
pub fn log_error(args: &fmt::Arguments) {
261+
js_console_error(&args.to_string());
262+
}
263+
246264
#[wasm_bindgen(js_class = WasmBindgenTestContext)]
247265
impl Context {
248266
/// Creates a new context ready to run tests.

0 commit comments

Comments
 (0)