How it works
Tests with
requires_login: true share an authenticated session. Bugster logs in once using the specified credential_id, then each subsequent test starts already authenticated—no repeated login flows.Prerequisites
Before using session persistence, you need:- Credentials configured in your
config.yaml— see Add credentials, roles & permissions - Environment variables set with your login secrets
Configure a test to require login
Add two fields to your test YAML:The ID of the credential profile to use for authentication. Must match a
credentials[].id in your config.yaml.Set to
true to indicate this test needs an authenticated session. Bugster will ensure the user is logged in before the test begins.How session persistence works
First test with requires_login runs
Bugster detects
requires_login: true and credential_id: user. It performs the login flow using the credentials from config.yaml.Session is cached
After successful authentication, Bugster stores the session (cookies, tokens, local storage) for reuse.
Session persistence works per
credential_id. If you have tests using different credentials (e.g., user vs admin), Bugster maintains separate sessions for each.Example: Multiple tests sharing a session
Here’s how a typical test suite might look with session persistence:config.yaml
Test 1: View profile (user)
Test 2: Edit profile (user)
Test 3: Admin dashboard (admin)
When to use session persistence
Use requires_login: true when...
Use requires_login: true when...
- Your test interacts with authenticated-only pages
- You’re testing features behind a login wall
- You want to verify user-specific data or permissions
- You’re running multiple tests that all need the same authenticated state
Don't use requires_login when...
Don't use requires_login when...
- The test is for public/unauthenticated pages
- You’re testing the login flow itself
- The test explicitly needs to start logged out
Performance benefits
Session persistence significantly reduces test execution time:| Scenario | Without persistence | With persistence |
|---|---|---|
| 10 tests requiring login | 10 login flows (~30s each) | 1 login flow |
| Total login overhead | ~5 minutes | ~30 seconds |
Pro tip: Group tests by
credential_id when running your suite. This maximizes session reuse and minimizes total execution time.Troubleshooting
Test fails saying user is not logged in
Test fails saying user is not logged in
- Verify
credential_idmatches exactly with acredentials[].idinconfig.yaml - Check that environment variables are set correctly in
.bugster/.env - Ensure the login page and flow haven’t changed
Session not persisting between tests
Session not persisting between tests
- Confirm both tests have
requires_login: true - Verify both tests use the same
credential_id - Check if your app has aggressive session timeouts
Wrong user in test
Wrong user in test
- Double-check the
credential_idin your test file - Verify environment variables point to the correct credentials
- Ensure you’re not mixing up credential IDs between environments
