MCPcopy Index your code
hub / github.com/coder/websocket / TestWasm

Function TestWasm

conn_test.go:445–472  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

443}
444
445func TestWasm(t *testing.T) {
446 t.Parallel()
447 if os.Getenv("CI") == "" {
448 t.SkipNow()
449 }
450
451 s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
452 err := echoServer(w, r, &websocket.AcceptOptions{
453 Subprotocols: []string{"echo"},
454 InsecureSkipVerify: true,
455 })
456 if err != nil {
457 t.Error(err)
458 }
459 }))
460 defer s.Close()
461
462 ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
463 defer cancel()
464
465 cmd := exec.CommandContext(ctx, "go", "test", "-exec=wasmbrowsertest", ".", "-v")
466 cmd.Env = append(cleanEnv(os.Environ()), "GOOS=js", "GOARCH=wasm", fmt.Sprintf("WS_ECHO_SERVER_URL=%v", s.URL))
467
468 b, err := cmd.CombinedOutput()
469 if err != nil {
470 t.Fatalf("wasm test binary failed: %v:\n%s", err, b)
471 }
472}
473
474func cleanEnv(env []string) (out []string) {
475 for _, e := range env {

Callers

nothing calls this directly

Calls 4

cleanEnvFunction · 0.85
echoServerFunction · 0.70
ErrorMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…