-
Notifications
You must be signed in to change notification settings - Fork 1
Integration Playwright
The Kronikol.Playwright package is the browser-driven end-to-end client for Kronikol. It mints a per-test identity, stamps the Kronikol test-tracking-* headers (and a W3C traceparent) on every request a Playwright IBrowserContext / IPage makes, and opens the matching in-process identity scope — so page→backend calls are attributed to the running test.
The sink is downstream, not the fixture. Where the calls get recorded depends on your topology:
| Backend | Sink | What to do |
|---|---|---|
Kronikol-instrumented (.NET, TestTrackingContextMiddleware + TestTrackingMessageHandler) |
the server | Nothing else — the middleware reads the headers and the handlers log under that identity. |
| Not instrumentable (polyglot, third-party, legacy) | a [[proxy tap | Integration-ProxyTap-Extension]] on each hop |
dotnet add package Kronikol.Playwrightusing Kronikol.Playwright;
using Microsoft.Playwright;
public class OverviewTests : IAsyncLifetime
{
private IPlaywright _pw = null!;
private IBrowser _browser = null!;
public async ValueTask InitializeAsync()
{
_pw = await Playwright.CreateAsync();
_browser = await _pw.Chromium.LaunchAsync(new() { Headless = true });
}
public async ValueTask DisposeAsync() { await _browser.DisposeAsync(); _pw.Dispose(); }
[Fact]
public async Task Overview_renders()
{
// One identity per test: name for the report, id = the correlation key
// (defaults to the identity's W3C trace id, so proxy taps can attribute by traceparent too).
var identity = TestTrackingIdentity.Create("overview › renders");
await using var context = await _browser.NewTrackedContextAsync(identity);
var page = await context.NewPageAsync();
await page.GotoAsync("http://localhost:4000/intelligence");
// ... assertions ...
// Report generation: Scenario.Id must equal identity.TestId.
}
}If your test framework already runs under a Kronikol adapter (xUnit/NUnit/MSTest/TUnit/… with TestIdentityScope set), use TestTrackingIdentity.FromCurrentScope() so the browser traffic joins the same scenario as your in-process HttpClient calls.
| Member | Purpose |
|---|---|
TestTrackingIdentity.Create(testName, testId?, callerName = "Browser", traceId?) |
Mint an identity. TestId defaults to TraceId.ToString("N") (32-hex = the W3C trace id). |
TestTrackingIdentity.FromCurrentScope() |
Build from the ambient TestIdentityScope. |
identity.ToHeaders() |
The four TestTrackingHttpHeaders (+ traceparent unless IncludeTraceparent = false). Values are ISO-8859-1-safe and ≤ 512 chars. |
browser.NewTrackedContextAsync(identity, options?) |
New context with the headers merged into ExtraHTTPHeaders. The per-test entry point.
|
context.UseTestTrackingAsync(identity, additionalHeaders?) / page.UseTestTrackingAsync(...)
|
Stamp an existing context/page (SetExtraHTTPHeadersAsync replaces the set — pass other headers you need via additionalHeaders). |
identity.BeginScope() |
Open the matching in-process TestIdentityScope (dispose to close). |
identity.Traceparent() |
A fresh sampled traceparent rooted at the identity's trace id. |
Browser ──(test-tracking-current-test-name / -current-test-id / -caller-name / -trace-id, traceparent)──►
your web app ──► graphql ──► data-insights ──► …
- A Kronikol-instrumented hop reads name+id (
TestTrackingContextMiddleware) and its outbound handlers re-stamp all four. - A
ProxyTapdoes the same from outside: it reads the headers, falls back to thetraceparenttrace id when a hop dropped them, and re-injects the four headers downstream. - Because
TestIddefaults to the W3C trace id, every hop — instrumented or tapped — lands in the same scenario, and the same id finds the distributed trace in Tempo/Jaeger.
The header names and the "test mints the trace, trace id = test id" convention are the contract for the planned @kronikol/playwright (Node) fixture and the Java port — a TypeScript Playwright fixture needs only context.setExtraHTTPHeaders({...}) with the same five headers. See Ingesting External Captures for the capture format those ports share.
Getting Started
Common Tasks
Integration Guides
- Integration xUnit3
- Integration xUnit2
- Integration NUnit
- Integration MSTest
- Integration TUnit
- Integration BDDfy xUnit3
- Integration LightBDD xUnit2
- Integration LightBDD xUnit3
- Integration LightBDD TUnit
- Integration ReqNRoll xUnit2
- Integration ReqNRoll xUnit3
- Integration ReqNRoll TUnit
- Integration Playwright
Uninstrumentable / polyglot backends
- Integration ProxyTap Extension
- Integration TcpTap Extension
- Integration Otlp Extension
- Exporting to OpenTelemetry
- Ingesting External Captures
- Integration Cucumber Messages
- Capture-Time Redaction
Extensions
- Integration AtlasDataApi Extension
- Integration BigQuery Extension
- Integration Bigtable Extension
- Integration BlobStorage Extension
- Integration ClickHouse Extension
- Integration CloudStorage Extension
- Integration CosmosDB Extension
- Integration Dapper Extension
- Integration DynamoDB Extension
- Integration EF Core Relational Extension
- Integration Elasticsearch Extension
- Integration EventBridge Extension
- Integration EventHubs Extension
- Integration Grpc Extension
- Integration Kafka Extension
- Integration MassTransit Extension
- Integration MongoDB Extension
- Integration MySqlConnector Extension
- Integration Npgsql Extension
- Integration Oracle Extension
- Integration PubSub Extension
- Integration Redis Extension
- Integration S3 Extension
- Integration ServiceBus Extension
- Integration SNS Extension
- Integration Spanner Extension
- Integration SqlClient Extension
- Integration Sqlite Extension
- Integration SQS Extension
- Integration StorageQueues Extension
- Integration OpenTelemetry Extension
- Integration DispatchProxy Extension
- Integration MediatR Extension
- Integration PlantUML IKVM
Configuration
- Tracking Dependencies
- Tracking Custom Dependencies
- HTTP Tracking Setup
- Report Configuration
- Diagram Customisation
- Phase-Aware Tracking
- Content Formatting
- PlantUML Server Configuration
Features
- Generated Reports
- Search Syntax
- Component Diagrams
- PlantUML Browser Rendering
- Inline SVG Rendering
- Internal Flow Tracking
- Tags and Attributes
- Excluding Requests
- Excluded Headers
- Multi-Host Test Architectures
- Event-Driven Architecture Testing
- Service Bus Tracking Patterns
- Background Thread Correlation
- Parallel-Safe Background Correlation
- Event & Message Tracking
- Assertion Tracking
- Step Tracking
- Tabular Attributes
- Large Response and Diagram Handling
- Querying Reports
- Diagnostics and Debugging
- CI Summary Integration
- CI Artifact Upload
- Merging Parallel Reports
Reference