relay Fixture
The relay fixture provides access to data from other tests within your tests.
Usage
import { test, expect } from 'playwright-relay';
/**
* @depends create user
*/
test('example', async ({ relay }) => {
const user = relay.from('create user');
console.log(user);
});
Methods
from<T>(testKey)
Get data from an executed test synchronously.
Parameters:
testKey- Test title or"file.spec.ts > title"for cross-file
Returns: The stored data
Throws: If test hasn't executed or failed
require<T>(testKey)
Get data, executing the dependency if needed.
Parameters:
testKey- Test title or"file.spec.ts > title"
Returns: Promise with the data
hasRun(testKey)
Check if a test has completed.
Returns: boolean
status(testKey)
Get current test status.
const status = relay.status('create user');
// 'pending' | 'running' | 'passed' | 'failed' | 'skipped'
all()
Get all cached results.
rerun<T>(testKey)
Force re-execution of a test.