@open-xchange/playwright-hindsight
v0.1.1
Published
Playwright reporter for sending test results to Hindsight
Maintainers
Keywords
Readme
@open-xchange/playwright-hindsight
Playwright reporter that sends test results to Hindsight.
Installation
npm install @open-xchange/playwright-hindsightConfiguration
In your playwright.config.ts:
import { defineConfig } from '@playwright/test'
export default defineConfig({
reporter: [
['list'],
['@open-xchange/playwright-hindsight', {
url: 'https://hindsight.example.com',
project: 'my-project',
client: 'playwright',
}],
],
})Options
All options can also be set via environment variables — useful for CI pipelines.
| Option | Env var | Default | Description |
|--------|---------|---------|-------------|
| url | HINDSIGHT_URL | http://localhost:8080 | Hindsight API base URL |
| branch | CI_COMMIT_REF_NAME | local | Git branch name |
| project | CI_PROJECT_PATH | hindsight | Project identifier |
| pipelineId | CI_PIPELINE_ID | — | CI pipeline ID |
| client | — | playwright | Client identifier |
| deployment | REPORT_PROJECT | — | Deployment identifier |
| clientId | HINDSIGHT_CLIENT_ID | — | OIDC client ID |
| clientSecret | HINDSIGHT_CLIENT_SECRET | — | OIDC client secret |
| tokenEndpoint | HINDSIGHT_TOKEN_ENDPOINT | — | Keycloak token endpoint |
Options passed in the config take precedence over environment variables.
Authentication
When clientId, clientSecret, and tokenEndpoint are provided (via options or env vars), the reporter authenticates using the OIDC client credentials flow. The token is cached and refreshed automatically.
When credentials are not configured, requests are sent without authentication — suitable for local development against an unprotected API.
What gets reported
After all tests complete, the reporter sends a single batch request to POST /api/v1/test-runs containing:
| Field | Source |
|-------|--------|
| feature | Test suite title (test.parent.title) |
| scenario | Test title |
| state | passed, failed, or skipped (timeouts → failed) |
| duration_ms | Test duration |
| time | Test start time (ISO 8601) |
| branch | From options or CI_COMMIT_REF_NAME |
| project | From options or CI_PROJECT_PATH |
| pipeline_id | From options or CI_PIPELINE_ID |
| client | From options (default: playwright) |
CI example (GitLab)
e2e tests:
variables:
HINDSIGHT_URL: https://hindsight.example.com
HINDSIGHT_TOKEN_ENDPOINT: https://keycloak.example.com/realms/my-realm/protocol/openid-connect/token
# HINDSIGHT_CLIENT_ID and HINDSIGHT_CLIENT_SECRET set as masked CI/CD variables
script:
- npx playwright testToken provider utility
The package also exports createTokenProvider for use in custom setup scripts (e.g., seeding test data):
import { createTokenProvider } from '@open-xchange/playwright-hindsight'
const provider = createTokenProvider({
clientId: process.env.HINDSIGHT_CLIENT_ID,
clientSecret: process.env.HINDSIGHT_CLIENT_SECRET,
tokenEndpoint: process.env.HINDSIGHT_TOKEN_ENDPOINT,
})
const token = await provider.getToken()Error handling
API errors are logged as warnings — they never fail the test run.
License
AGPL-3.0-or-later
