net/http: improve useFakeNetwork check to allow browsers to run tests in wasm #32289
Labels
arch-wasm
WebAssembly issues
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
go version
)?net/http/rountrip_js.go has this code:
This code has gone through several iterations. First it was:
Then, it was changed to:
And finally,
The latest version will always return true if any code is invoked with
go test
. That prevents wasm codepath from being taken if the test is being run using a binary (by replacing the-exec
flag) which spins up a browser, and loads the wasm file in it and captures the logs. Essentially a test environment for wasm code inside the browser.I stumbled onto this while writing a tool like that. The current workaround from my end is to rename the binary to .wasm if it ends with .test. But ideally, this should be fixed in the code.
@johanbrandhorst @neelance @bradfitz
The text was updated successfully, but these errors were encountered: