github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/tests/wasm/log_test.go (about) 1 package wasm 2 3 import ( 4 "testing" 5 6 "github.com/chromedp/chromedp" 7 ) 8 9 func TestLog(t *testing.T) { 10 11 wasmTmpDir, server := startServer(t) 12 13 err := run(t, "tinygo build -o "+wasmTmpDir+"/log.wasm -target wasm testdata/log.go") 14 if err != nil { 15 t.Fatal(err) 16 } 17 18 ctx := chromectx(t) 19 20 var log1 string 21 err = chromedp.Run(ctx, 22 chromedp.Navigate(server.URL+"/run?file=log.wasm"), 23 chromedp.InnerHTML("#log", &log1), 24 waitLogRe(`^..../../.. ..:..:.. log 1 25 ..../../.. ..:..:.. log 2 26 ..../../.. ..:..:.. log 3 27 println 4 28 fmt.Println 5 29 ..../../.. ..:..:.. log 6 30 in func 1 31 ..../../.. ..:..:.. in func 2 32 $`), 33 ) 34 t.Logf("log1: %s", log1) 35 if err != nil { 36 t.Fatal(err) 37 } 38 39 }