
These wasm tests weren't passing in GitHub Actions and also weren't passing on my laptop. I'm not sure why, I think there are a few race conditions that are going on. This commit attempts to fix this at least to a degree: - The context deadline is increased from 5 seconds to 10 seconds. - The tests are not running in parallel anymore. - Some `Sleep` calls were removed, they do not appear to be necessary (and if they were, sleeping is the wrong solution to solve race conditions). Overall the tests are taking a few seconds more, but on the other hand they seem to be passing more reliable. At least for me, on my laptop (and hopefully also in CI).
42 строки
691 Б
Go
42 строки
691 Б
Go
package wasm
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/chromedp/chromedp"
|
|
)
|
|
|
|
func TestEvent(t *testing.T) {
|
|
|
|
wasmTmpDir, server := startServer(t)
|
|
|
|
err := run(t, "tinygo build -o "+wasmTmpDir+"/event.wasm -target wasm testdata/event.go")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
ctx, cancel := chromectx()
|
|
defer cancel()
|
|
|
|
var log1, log2 string
|
|
err = chromedp.Run(ctx,
|
|
chromedp.Navigate(server.URL+"/run?file=event.wasm"),
|
|
chromedp.WaitVisible("#log"),
|
|
chromedp.InnerHTML("#log", &log1),
|
|
waitLog(`1
|
|
4`),
|
|
chromedp.Click("#testbtn"),
|
|
chromedp.InnerHTML("#log", &log2),
|
|
waitLog(`1
|
|
4
|
|
2
|
|
3
|
|
true`),
|
|
)
|
|
t.Logf("log1: %s", log1)
|
|
t.Logf("log2: %s", log2)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
}
|