Documentation
¶
Overview ¶
Package bdd wires the hex/webtest client into a hex/bdd suite as a set of standard Gherkin step definitions, giving apps a react-testing-library-flavoured browser-test vocabulary in .feature files:
Feature: dashboard
Scenario: authenticated user sees welcome
When I visit "/dashboard"
Then the response status should be 200
And I should see "Welcome, Alice"
And "h1" should have text "Welcome, Alice"
And there should be 3 elements matching ".user-card"
And "button[data-testid=add-user]" should exist
Scenario: bad credentials
When I post form to "/login":
| email | user@example.com |
| password | wrong |
Then the response status should be 401
And I should see "bad credentials"
Usage from a test:
func TestFeatures(t *testing.T) {
app := hextest.NewApp(t, myproviders...)
suite := bdd.NewSuite(t)
webtestbdd.Register(suite, func() *webtest.Client {
return webtest.New(t, app)
})
suite.Run()
}
The Client factory is called ONCE PER SCENARIO so each scenario gets a fresh cookie jar and a clean request state. State that should persist across scenarios (seeded rows, cached files, etc.) belongs on the app itself, not the client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.