npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@zest-pw/test

v1.0.9

Published

Advanced Playwright test framework with automatic screenshots, custom reporting, and Zephyr Scale integration

Downloads

575

Readme

Zest Playwright Test Framework

Advanced Playwright test framework with automatic screenshots, custom reporting, and Zephyr Scale integration.

✨ Features

  • 📸 Automatic Screenshots - Capture screenshots after each test step
  • 📊 Custom JSON Reports - Detailed test results with step information
  • 🔄 Zephyr Scale Integration - Automatically update test results in Zephyr
  • ⚙️ Type-Safe Configuration - Configure behavior via zest.config.ts
  • 🎯 Step-by-Step Tracking - Detailed information about each test step
  • 🖼️ Base64 Screenshots in Reports - Screenshots embedded directly in JSON

🚀 Quick Start

Requirements

  • Node.js >= 18.0.0
  • Playwright (peer dependency)

1. Install the Package

npm install --save-dev @zest-pw/test

2. Configuration

The configuration file zest.config.ts will be automatically created in your project root after installation.

The default configuration:

import { defineZestConfig } from '@zest-pw/test';

export default defineZestConfig({
  reporter: {
    saveJsonReport: true,
    printToConsole: true,
    outputDir: 'test-results',
  },
  screenshots: {
    enabled: true,
    includeInReport: true,
    onlyOnFailure: false,
  },
  zephyr: {
    enabled: false,
    updateResults: false,
  },
});

3. Configure Playwright

Update your playwright.config.ts:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: [
    ['list'],
    ['@zest-pw/test/reporter'], // Add Zest reporter
  ],
  // ... other Playwright config
});

4. Write Your First Test

import { test, expect } from '@zest-pw/test';

test('TC-001: Check the title', async ({ page }) => {
  
  await test.step('Go to the playwright website', async () => {
    await page.goto('https://playwright.dev/');
  });

  await test.step('Check the title', async () => {
    await expect(page).toHaveTitle(/Playwright/);
  });
});

5. Run Tests

npx playwright test

⚙️ Configuration

Configuration File

The zest.config.ts file is automatically created when you install the package. You can customize it as needed:

import { defineZestConfig } from '@zest-pw/test';

export default defineZestConfig({
  reporter: {
    // Save test results to JSON file
    saveJsonReport: true,
    
    // Output directory for reports
    outputDir: 'test-results',
    
    // Print test results to console
    printToConsole: false,
  },

  screenshots: {
    // Enable screenshot capture
    enabled: true,
    
    // Include screenshots in JSON report
    includeInReport: true,
    
    // Capture screenshots only on failure
    onlyOnFailure: false,
  },

  zephyr: {
    // Enable Zephyr Scale integration
    enabled: false,
    
    // Update test results in Zephyr after test run
    updateResults: false,
  },
});

For detailed configuration options, see CONFIG.md.

📸 Screenshots

Screenshots are automatically captured after each test.step() and:

  • Embedded in JSON report as base64 (if includeInReport: true)
  • Named descriptively based on step title and index
  • Include error screenshots when tests fail

Screenshot Settings

screenshots: {
  enabled: true,           // Enable/disable screenshots
  includeInReport: true,   // Include in JSON report
  onlyOnFailure: false,    // Capture only on test failure
}

Example Screenshot Output

{
  "fileName": "step_1_go_to_the_playwright_website.png",
  "image": "image/png",
  "body": "base64_encoded_screenshot..."
}

📊 Test Reports

JSON Report

Test results are automatically saved to test-results/test-results.json:

{
  "tests": [
    {
      "projectName": "chromium",
      "testTitle": "Check the title",
      "testCaseKey": "TC-001",
      "steps": [
        {
          "stepTitle": "Go to the playwright website",
          "actualResult": [...],
          "statusName": "pass"
        }
      ]
    }
  ]
}

Console Output

Enable console output in your config:

reporter: {
  printToConsole: true,
}

🔄 Zephyr Scale Integration

Setup

  1. Add environment variables:
# .env
ZEPHYR_API_URL=https://api.zephyrscale.smartbear.com/v2/
ZEPHYR_API_KEY=your-api-key
ZEPHYR_TEST_CYCLE_KEY=TEST-CYCLE-123
  1. Enable in configuration:
zephyr: {
  enabled: true,
  updateResults: true,
}
  1. Run tests - results will be automatically sent to Zephyr!

How it Works

  • Test case keys are extracted from test file names (e.g., TC-001.spec.tsTC-001)
  • After test execution, results are sent to Zephyr Scale
  • Test steps are updated with actual results and screenshots

🛠️ Project Structure

your-project/
├── node_modules/
│   └── @zest-pw/
│       └── test/          # Installed package
├── tests/                 # Test files
│   ├── TC-001.spec.ts
│   └── TC-002.spec.ts
├── test-results/          # Test results
│   └── test-results.json
├── zest.config.ts         # Zest configuration (auto-created)
├── playwright.config.ts   # Playwright configuration
└── package.json

📝 Writing Tests

Basic Test Structure

import { test, expect } from '@zest-pw/test';

test('TC-001: Test description', async ({ page }) => {
  
  await test.step('Step 1 description', async () => {
    // Your test code
  });

  await test.step('Step 2 description', async () => {
    // Your test code
  });
});

Test Naming Convention

Name your test files with test case keys for Zephyr integration:

tests/
├── TC-001.spec.ts   ✅ Good - extracts "TC-001"
├── TC-002.spec.ts   ✅ Good - extracts "TC-002"
└── login.spec.ts    ⚠️  Will not sync with Zephyr

Best Practices

  1. Use descriptive step names - they become screenshot filenames
  2. One test per file - easier to manage and sync with Zephyr
  3. Keep steps atomic - each step should be a single action or assertion
  4. Use test case keys - for Zephyr integration

💡 Commands

# Run all tests
npx playwright test

# Run specific test
npx playwright test tests/TC-001.spec.ts

# Run in headed mode
npx playwright test --headed

# Run in debug mode
npx playwright test --debug

# Run with UI
npx playwright test --ui

# Generate Playwright report
npx playwright show-report

🔧 Advanced Usage

Custom Configuration per Environment

const isDev = process.env.NODE_ENV === 'development';
const isCI = process.env.CI === 'true';

export default defineZestConfig({
  reporter: {
    printToConsole: isDev,
  },
  screenshots: {
    onlyOnFailure: isCI,
  },
  zephyr: {
    enabled: isCI,
    updateResults: isCI,
  }
});

Accessing Configuration in Code

import { getZestConfig } from '@zest-pw/test';

const config = getZestConfig();
console.log('Screenshots enabled:', config.screenshots.enabled);

Programmatic Configuration

import { defineZestConfig } from '@zest-pw/test';

export default defineZestConfig({
  reporter: {
    saveJsonReport: process.env.SAVE_REPORTS !== 'false',
    outputDir: process.env.REPORT_DIR || 'test-results',
  }
});

🐛 Troubleshooting

Configuration file setup

The zest.config.ts file is automatically created when you install the package. If it wasn't created, you can create it manually using the template from the Configuration section.

Screenshots not appearing in report

Check your configuration:

screenshots: {
  enabled: true,
  includeInReport: true,
}

Zephyr integration not working

  1. Verify environment variables are set
  2. Check test case keys match Zephyr format
  3. Enable Zephyr in configuration
  4. Check API credentials and permissions

JSON report not saved

Ensure configuration allows saving:

reporter: {
  saveJsonReport: true,
}

Import errors

Make sure you're importing from the installed package:

// ✅ Correct
import { test, expect, defineZestConfig } from '@zest-pw/test';

// ❌ Incorrect (old local paths)
import { test, expect } from './zest-pw/fixtures/fixtures';

📚 Documentation

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

📄 License

MIT License - see LICENSE file for details