aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/wasm/fmtprint_test.go
blob: 7b4a4701a366809e2a4b9ee7d0249c97c0c61251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// +build go1.14

package wasm

import (
	"testing"
	"time"

	"github.com/chromedp/chromedp"
)

func TestFmtprint(t *testing.T) {

	t.Parallel()

	wasmTmpDir, server, cleanup := startServer(t)
	defer cleanup()

	err := run("tinygo build -o " + wasmTmpDir + "/fmtprint.wasm -target wasm testdata/fmtprint.go")
	if err != nil {
		t.Fatal(err)
	}

	ctx, cancel := chromectx(5 * time.Second)
	defer cancel()

	var log1 string
	err = chromedp.Run(ctx,
		chromedp.Navigate(server.URL+"/run?file=fmtprint.wasm"),
		chromedp.Sleep(time.Second),
		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)
	}

}