browsertest

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package browsertest provides Playwright helpers for end-to-end browser tests against a gin-kit application. Tests skip cleanly when the Playwright driver or browsers are not installed, so `go test ./...` stays green on machines and CI runners without them.

One-time local setup:

go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps chromium

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install() error

Install downloads the Playwright driver and Chromium. Intended for one-time local setup or provisioning scripts.

func StartServer

func StartServer(t *testing.T, application *runtime.Application) string

StartServer serves the application's router on 127.0.0.1 with a random port and returns the base URL (e.g. http://127.0.0.1:41234). It uses a plain HTTP server — not Application.Run — so there is no signal handling or fixed address; shutdown and application cleanup happen via t.Cleanup.

Types

type Browser

type Browser struct {
	// PW store data used by this type.
	PW *playwright.Playwright
	// Chromium store data used by this type.
	Chromium playwright.Browser
}

Browser bundles a running Playwright driver and a Chromium instance.

func Launch

func Launch(t *testing.T) *Browser

Launch starts Playwright and Chromium, or skips the test: when PLAYWRIGHT_SKIP is set, or when the driver/browsers are not installed. Everything stops via t.Cleanup.

func (*Browser) NewPage

func (b *Browser) NewPage(t *testing.T) playwright.Page

NewPage opens a page that closes with the test.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL