Skip to Content

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:

BenefitDescription
TraceabilityLink tests β†’ journeys β†’ requirements
ObservabilityCentralized dashboards showing test health
Coverage TrackingIdentify gaps in test coverage
Trend AnalysisTrack 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

Installation

Install packages

npm install @lytics/playwright-annotations @lytics/playwright-reporter @lytics/playwright-adapters

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;

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 test

Architecture

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

Read the documentation β†’

MIT License β€’ Built by ContentstackΒ 

Last updated on