github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/tests/wasm/fmtprint_test.go (about)

     1  package wasm
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/chromedp/chromedp"
     7  )
     8  
     9  func TestFmtprint(t *testing.T) {
    10  
    11  	wasmTmpDir, server := startServer(t)
    12  
    13  	err := run(t, "tinygo build -o "+wasmTmpDir+"/fmtprint.wasm -target wasm testdata/fmtprint.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=fmtprint.wasm"),
    23  		chromedp.InnerHTML("#log", &log1),
    24  		waitLog(`test from fmtprint 1
    25  test from fmtprint 2
    26  test from fmtprint 3
    27  test from fmtprint 4`),
    28  	)
    29  	t.Logf("log1: %s", log1)
    30  	if err != nil {
    31  		t.Fatal(err)
    32  	}
    33  
    34  }