wasm_bindgen_test/rt/
node.rs1use alloc::format;
7use alloc::string::String;
8use wasm_bindgen::prelude::*;
9
10use super::TestResult;
11
12pub struct Node {}
14
15#[wasm_bindgen]
16extern "C" {
17 type NodeError;
20 #[wasm_bindgen(method, getter, js_class = "Error", structural)]
21 fn stack(this: &NodeError) -> String;
22 #[wasm_bindgen(js_name = __wbgtest_og_console_log)]
23 fn og_console_log(s: &str);
24}
25
26impl Node {
27 pub fn new() -> Node {
29 Node {}
30 }
31}
32
33impl super::Formatter for Node {
34 fn writeln(&self, line: &str) {
35 og_console_log(line);
36 }
37
38 fn log_test(&self, name: &str, result: &TestResult) {
39 self.writeln(&format!("test {} ... {}", name, result));
40 }
41
42 fn stringify_error(&self, err: &JsValue) -> String {
43 NodeError::from(err.clone()).stack()
45 }
46}