Wasm-bindgen: Don't print console logs if all tests pass

Created on 15 Jan 2019  路  8Comments  路  Source: rustwasm/wasm-bindgen

If all the #[wasm_bindgen_test]s pass, then we shouldn't spam the console with the console.log output.

wasm-bindgen-test

Most helpful comment

FWIW, cargo test won't show println!s from passing tests.

All 8 comments

Would this include console.log calls from the user? If so that might lead to some confusion.

@chinedufn I think that's pretty standard. If I recall correctly, Jest doesn't show console.log calls unless the test actually failed.

I think showing unrelated console.logs from passing tests might be more confusing.

@Pauan In both JS (I don't use Jest I use tape) and Rust I'll frequently be TDD'ing and want to print something out real quick and see what's going on.

I could see some friction if whether or not I saw my quick little prints was determined by whether or not my tests were passing at that time.

However I admittedly haven't used wasm-bindgen-test very much yet so I'll defer here!

FWIW, cargo test won't show println!s from passing tests.

Not by default but you can pass a --nocapture flag in to turn it on (that鈥檚 what I do). If that鈥檚 feasible could be nice here

Not by default but you can pass a --nocapture flag in to turn it on (that鈥檚 what I do). If that鈥檚 feasible could be nice here

Oh, yeah that seems very reasonable!

I could see some friction if whether or not I saw my quick little prints was determined by whether or not my tests were passing at that time.

You can always add an assert!(false) to a test to make it fail.

Although the --nocapture approach is much nicer.

I'd very much welcome console log output capturing. If you log a lot, it's very hard to see what's going on.

You can always add an assert!(false) to a test to make it fail.

Sorry not to bikeshed here ........ but this wouldn't work for me as I'll sometimes toss a quick log in just to see if a code path was followed so if I forgot to add a false assertion I'd wrongly think that it wasn't until I remembered that my logs were hidden at the moment because tests were passing.

--nocapture sounds like it works for everyone though!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bantic picture bantic  路  4Comments

poccariswet picture poccariswet  路  3Comments

fitzgen picture fitzgen  路  4Comments

aschampion picture aschampion  路  4Comments

NateLing picture NateLing  路  3Comments