tinygo/tests/wasm/fmtprint_test.go
Nia Waldvogel 7c3a22d289 wasmtest: fix resource cleanup and add logging
The chromedp context was not cancelled, so resources may have been leaking.
Additionally this waits for the browser to start before the timer starts, and extends the timeout to 20 seconds.
Logging from chromedp has also been enabled, which may help identify possible issues?
2022-01-18 19:29:29 +01:00

34 строки
602 Б
Go

package wasm
import (
"testing"
"github.com/chromedp/chromedp"
)
func TestFmtprint(t *testing.T) {
wasmTmpDir, server := startServer(t)
err := run(t, "tinygo build -o "+wasmTmpDir+"/fmtprint.wasm -target wasm testdata/fmtprint.go")
if err != nil {
t.Fatal(err)
}
ctx := chromectx(t)
var log1 string
err = chromedp.Run(ctx,
chromedp.Navigate(server.URL+"/run?file=fmtprint.wasm"),
chromedp.InnerHTML("#log", &log1),
waitLog(`test from fmtprint 1
test from fmtprint 2
test from fmtprint 3
test from fmtprint 4`),
)
t.Logf("log1: %s", log1)
if err != nil {
t.Fatal(err)
}
}