Skip to content

v0.0.5 - Custom Fixture Support for YAML Tests

Choose a tag to compare

@gurvinder-dhillon gurvinder-dhillon released this 22 Dec 01:52
· 54 commits to main since this release
Immutable release. Only release title and notes can be modified.

πŸŽ‰ What's New

Custom Fixture Support for YAML Tests

YAML tests can now import custom Playwright fixtures, enabling advanced use cases like cloud browsers, custom test data, and authentication fixtures.

Example:

name: Cloud Browser Tests
fixtureFile: ./fixtures/browser.js  # Import custom fixtures

tests:
  - name: Test with cloud browser
    steps:
      - Navigate to https://example.com
      - Add laptop to cart

Fixture file:

// fixtures/browser.js
import { test as base } from '@playwright/test';
import { chromium } from '@playwright/test';

export const test = base.extend({
  browser: [async ({}, use) => {
    const browser = await chromium.connectOverCDP('ws://your-cloud-browser');
    await use(browser);
    await browser.close();
  }, { scope: 'worker' }],
});

πŸ“¦ Changes

  • Added `fixtureFile` property to YAML schema for importing custom Playwright fixtures
  • Path validation: requires relative paths starting with `./` or `../`
  • File type validation: only `.js` and `.ts` extensions allowed
  • Full backward compatibility: existing YAML tests work unchanged

πŸ“š Examples

  • OnKernel cloud browser: `examples/playwright-yaml/fixtures/onkernel.js`
  • Steel Docker browser: `examples/playwright-yaml/fixtures/steel.js`
  • YAML usage: `examples/playwright-yaml/tests/onkernel.spec.yaml`
  • Steel BDD example: `examples/playwright-bdd-steel/`

πŸ”§ Technical Details

Files Modified

  • `src/yaml/schema.js` - Added fixtureFile validation
  • `src/yaml/generator.js` - Conditional import generation with path resolution
  • `src/cli/generate.js` - Pass absolute YAML path for fixture resolution
  • `README.md` - Added fixture documentation and examples

Path Resolution

Fixture paths are resolved relative to the YAML file location and work identically in both development and production environments. No hardcoded paths or assumptions about package location.

πŸ“– Documentation

Updated README with:

  • YAML custom fixtures quick start example
  • Cloud browser fixture patterns
  • Updated examples list

πŸ”— Links