# Testing (laravel-go-captcha)

> The captchatest package helps your application's tests get past a captcha without reading the image.

- Package: laravel-go-captcha (Laravel for Go, alpha), go modules: `github.com/bowerbird-si/laravel-go-captcha`
- Maintenance: active; Latest release: 0.1.0 (2026-12-04); Framework: go.laravel.com v0.2.0 or later; Go: Go 1.27 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/laravel-go-captcha), [pkg.go.dev](https://pkg.go.dev/github.com/bowerbird-si/laravel-go-captcha@v0.1.0), [Changelog](https://oss.bowerbird.si/go-captcha/docs/changelog/), [Contributing](https://github.com/bowerbird-si/laravel-go-captcha/blob/7a10d1c56d2e1a3e3e6618d025657dda5d5385cf/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/laravel-go-captcha/blob/7a10d1c56d2e1a3e3e6618d025657dda5d5385cf/SECURITY.md)
- Based on: [mews/captcha](https://github.com/mewebstudio/captcha): The captcha package this ports: profiles, config keys, routes and validation, following version 3.5.1. Its bundled fonts ship with their own licences.
- PHP parity: core (52 covered, 35 diverged, 0 planned of 87 abilities; 44 fixtures; follows mews/captcha 3.5.1; verified 2026-12-04)
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/go-captcha/docs/testing/
- Source: https://github.com/bowerbird-si/laravel-go-captcha/blob/7a10d1c56d2e1a3e3e6618d025657dda5d5385cf/docs/testing.md

The `captchatest` package helps your application's tests get past a captcha without reading the image.

## Turn the captcha off

```go
client := laraveltest.New(t, options, captchatest.Disable())
```

Every rule passes and the routes aren't registered, in that test application only.

## Answer it

To test the real flow, record the answers the package issues. A test application runs in one process, so
it can use the `memory` cache with `CAPTCHA_SINGLE_PROCESS=true`:

```go
pkg := captcha.New()
rec := captchatest.Record(pkg)
client := laraveltest.New(t, laravel.Options{Packages: []laravel.Package{pkg}},
	laraveltest.Env(map[string]string{"CAPTCHA_SINGLE_PROCESS": "true"}))

client.Get("/captcha/default").AssertOK()
client.Post("/contact", url.Values{
	"message": {"Hello"},
	"captcha": {rec.Answer(t, "default")},
}).AssertRedirect("/thanks")
```

- `rec.Answer(t, profile)` returns the answer of the latest session image for that profile.
- `rec.AnswerFor(t, key)` returns the answer of a keyed challenge.

Build a new package value for each test application. A recorder only sees answers issued by its own
package value, so parallel tests can't read each other's answers. Production code never keeps answers.
