E2E Test Generator
When to Use
- Generate tests for a feature spec
- Validate acceptance criteria with automated tests
- Keep tests in sync with specs
Core Principle
Tests come from specs. Each acceptance criterion should have a corresponding test.
Process
- Read the feature spec's acceptance criteria
- Map each criterion to a test scenario
- Generate tests using project's test framework
- Run tests to verify implementation
Mapping Criteria to Tests
For each acceptance criterion:
| Criterion | Test |
|---|---|
[ ] User can [action] |
test('user can [action]') |
[ ] System [behavior] |
test('system [behavior]') |
Test Structure
describe('Feature: [Name]', () => {
beforeEach(async () => {
// Setup
});
test('[criterion from spec]', async () => {
// Arrange
// Act
// Assert
});
});
Principles
One test per criterion:
// Spec: [ ] User can adjust timer from 5–90 minutes
test('user can adjust timer from 5 to 90 minutes', async () => {
// ...
});
Test names match spec language:
- Spec says "User can pause and resume"
- Test named "user can pause and resume"
Test user value, not implementation:
- ❌
test('component state updates') - ✅
test('user sees updated value')
Edge cases get additional tests:
- Spec mentions edge case in Key Interactions
- Create separate test for that edge case
Mocking
Mock:
- External APIs
- Device APIs (speech, audio)
- Long-running operations
Don't mock:
- UI interactions
- Local state
- Core business logic
Test Maintenance
When spec changes:
- Criterion added → Add test
- Criterion modified → Update test
- Criterion removed → Remove test
Framework Examples
Playwright
test('user can [action]', async ({ page }) => {
await page.goto('/feature');
await page.click('[data-testid="button"]');
await expect(page.locator('[data-testid="result"]')).toBeVisible();
});
Cypress
it('user can [action]', () => {
cy.visit('/feature');
cy.get('[data-testid="button"]').click();
cy.get('[data-testid="result"]').should('be.visible');
});
Summary
✅ Tests come from specs ✅ One test per criterion ✅ Test names match spec language ✅ Tests validate user value ✅ Tests stay in sync with specs
Converted and distributed by TomeVault — claim your Tome and manage your conversions.