playwright-core
Annotation-driven Playwright testing infrastructure for better observability and traceability.
Get Started Β· View on GitHubΒ
Now Available β @lytics/playwright-annotations@0.2.0, @lytics/playwright-reporter@0.1.1, @lytics/playwright-adapters@1.0.1 View releases βΒ
Open Source β Generic testing infrastructure that any team can use. Built by Contentstack for Playwright testing at scale.
Why Annotation-Driven Testing?
Every test is annotated with metadata linking it to user journeys and business requirements:
ACCOUNT_SECURITY (Test Suite)
βββ ACCOUNT_SECURITY_VIEW-TOKENS (Journey)
β βββ ACCOUNT_SECURITY_VIEW-TOKENS_VALID (Test Case)
β βββ ACCOUNT_SECURITY_VIEW-TOKENS_EMPTY (Test Case)
βββ ACCOUNT_SECURITY_CREATE-TOKEN (Journey)
βββ ACCOUNT_SECURITY_CREATE-TOKEN_VALID (Test Case)Benefits:
| Benefit | Description |
|---|---|
| Traceability | Link tests β journeys β requirements |
| Observability | Centralized dashboards showing test health |
| Coverage Tracking | Identify gaps in test coverage |
| Trend Analysis | Track test stability per journey, per suite |
Quick Example
Step 1: Create a reporter file
// reporter.ts
import { CoreReporter } from "@lytics/playwright-reporter";
import { FilesystemAdapter } from "@lytics/playwright-adapters/filesystem";
class CustomReporter extends CoreReporter {
constructor() {
super({
adapters: [new FilesystemAdapter({ outputDir: './test-results' })]
});
}
}
export default CustomReporter;Step 2: Configure Playwright
// playwright.config.ts
export default {
reporter: [['list'], ['./reporter.ts']]
};Step 3: Write annotated tests
// tests/account-security.spec.ts
import { test } from "@playwright/test";
import { pushSuiteAnnotation, pushTestAnnotations } from "@lytics/playwright-annotations";
test.describe("Account Security @smoke", () => {
test.beforeEach(async ({}, testInfo) => {
pushSuiteAnnotation(testInfo, "ACCOUNT_SECURITY");
});
test("user can view access tokens", async ({}, testInfo) => {
pushTestAnnotations(testInfo, {
journeyId: "ACCOUNT_SECURITY_VIEW-TOKENS",
testCaseId: "ACCOUNT_SECURITY_VIEW-TOKENS_VALID",
});
// Your test implementation...
});
});Packages
Annotation framework with type-safe helpers and validation
@lytics/playwright-annotationsAdapter-based reporter with pluggable storage backends
@lytics/playwright-reporterStorage adapters: Filesystem, Slack, Firestore
@lytics/playwright-adaptersInstallation
Install packages
npm install @lytics/playwright-annotations @lytics/playwright-reporter @lytics/playwright-adaptersCreate a reporter file
// reporter.ts
import { CoreReporter } from '@lytics/playwright-reporter';
import { FilesystemAdapter } from '@lytics/playwright-adapters/filesystem';
class CustomReporter extends CoreReporter {
constructor() {
super({
adapters: [new FilesystemAdapter({ outputDir: './test-results' })]
});
}
}
export default CustomReporter;Configure Playwright
// playwright.config.ts
export default {
reporter: [['list'], ['./reporter.ts']]
};Add annotations to tests
import { pushSuiteAnnotation, pushTestAnnotations } from '@lytics/playwright-annotations';
test.describe('My Feature', () => {
test.beforeEach(async ({}, testInfo) => {
pushSuiteAnnotation(testInfo, 'MY_FEATURE');
});
test('validates user action', async ({}, testInfo) => {
pushTestAnnotations(testInfo, {
journeyId: 'MY_FEATURE_ACTION',
testCaseId: 'MY_FEATURE_ACTION_VALID',
});
// Test implementation...
});
});Run tests
npx playwright testArchitecture
annotations (base - no dependencies)
β
reporter (depends on: annotations)
β
adapters (depends on: reporter, annotations)The packages are designed to be modular:
- Use annotations standalone for type-safe test metadata
- Add reporter to collect and process results
- Choose adapters for your storage needs (local, Slack, Firestore)
Features
- Type-Safe Annotations β Full TypeScript support with extensible schemas
- Flexible Validation β Built-in rules or create your own
- Multiple Adapters β Write results to filesystem, Slack, Firestore, or custom backends
- Retry Handling β Intelligent deduplication and flaky test detection
- Environment Enrichment β Add CI/CD metadata to test runs
MIT License β’ Built by ContentstackΒ