aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/wasm/log_test.go
blob: a9cc1befaa7c307b9de593547c6965497f9f4667 (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
43
44
// +build go1.14

package wasm

import (
	"testing"
	"time"

	"github.com/chromedp/chromedp"
)

func TestLog(t *testing.T) {

	t.Parallel()

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

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

	var log1 string
	err = chromedp.Run(ctx,
		chromedp.Navigate("http://localhost:8826/run?file=log.wasm"),
		chromedp.Sleep(time.Second),
		chromedp.InnerHTML("#log", &log1),
		waitLogRe(`^..../../.. ..:..:.. log 1
..../../.. ..:..:.. log 2
..../../.. ..:..:.. log 3
println 4
fmt.Println 5
..../../.. ..:..:.. log 6
in func 1
..../../.. ..:..:.. in func 2
$`),
	)
	t.Logf("log1: %s", log1)
	if err != nil {
		t.Fatal(err)
	}

}