INNER CODE UNIT · Go

TestWaitForDevTools

charmbracelet/vhs · browser_test.go:61

func TestWaitForDevTools(t *testing.T) {
	t.Run("becomes ready", func(t *testing.T) {
		ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
			w.WriteHeader(http.StatusOK)
		}))
		defer ts.Close()

		_, port, err := net.SplitHostPort(ts.Listener.Addr().String())
		if err != nil {
			t.Fatal(err)
		}

		if !waitForDevTools(context.Background(), mustAtoi(t, port), nil, time.Second) {
			t.Error("expected the endpoint to become ready")
		}
	})

	t.Run("times out when nothing is listening", func(t *testing.T) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…