Skip to content

Commit

Permalink
eventloop: add small async/await syntax test
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Jan 9, 2023
1 parent e524b0e commit 72aec24
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions js/eventloop/eventloop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,22 @@ func TestEventLoopRejectThrow(t *testing.T) {
loop.WaitOnRegistered()
require.EqualError(t, err, "Uncaught (in promise) GoError: throw error\n\tat go.k6.io/k6/js/eventloop_test.TestEventLoopRejectThrow.func1 (native)\n\tat <eval>:1:31(2)\n")
}

func TestEventLoopAsyncAwait(t *testing.T) {
t.Parallel()
vu := &modulestest.VU{RuntimeField: goja.New()}
loop := eventloop.New(vu)
err := loop.Start(func() error {
_, err := vu.Runtime().RunString(`
async function a() {
some.error.here
}
Promise.resolve().then(async () => {
await a();
})
`)
return err
})
loop.WaitOnRegistered()
require.EqualError(t, err, "Uncaught (in promise) ReferenceError: some is not defined\n\tat a (<eval>:3:13(1))\n\tat <eval>:6:20(2)\n")
}

0 comments on commit 72aec24

Please sign in to comment.