v0.0.5 - Custom Fixture Support for YAML Tests
·
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 cartFixture 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
- npm: https://www.npmjs.com/package/openqa
- Documentation: https://github.com/openqa-labs/openqa