Wasm test code, how to use syscall/js to create a document when invoked in node.js

59 views
Skip to first unread message

John

unread,
Aug 25, 2020, 6:29:25 PM8/25/20
to golang-nuts
I am using the following to run wasm tests:

GOOS=js GOARCH=wasm go test -exec "node $(go env GOROOT)/misc/wasm/wasm_exec

Because I'm in a node environment, the Global().Get("document") is empty.

I need to be able to populate that with the correct document object so I can test DOM manipulation.  However, I am not sure how to do this.  The document needs to be some specific object type and not a string representing the page,  which I could achieve with .Set(string).

In javascript, I believe you can do:

document.implementation.createHTMLDocument()

Anyone know if this is possible to do from syscall/js and if so how to do this?

Thanks!
Reply all
Reply to author
Forward
0 new messages