Skip to content

Add plain-steps test case generator with Playwright HTML report - #198

Open
sanjeevkumarcspl wants to merge 1 commit into
github-samples:mainfrom
sanjeevkumarcspl:sanjeevkumarcspl-test-case-generator
Open

sanjeevkumarcspl wants to merge 1 commit into
github-samples:mainfrom
sanjeevkumarcspl:sanjeevkumarcspl-test-case-generator

Conversation

@sanjeevkumarcspl

Copy link
Copy Markdown

Description

Adds a small generator that turns a plain-text test case (Given/When/Then steps) into a Playwright spec with reusable step methods, and enables the Playwright HTML report so each step appears in the report.

Related Issue

Closes #184

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation update
  • 🧪 Test update
  • 🔧 Refactor (no functional changes)

Changes Made

  • scripts/test-generator/generator.ts: pure parser and spec generator; unknown steps become stubs that fail with "Step not implemented"
  • scripts/test-generator/cli.ts and npm run test:generate -- <steps-file>
  • e2e-tests/steps/common-steps.ts: reusable step methods
  • e2e-tests/test-cases/ (sample inputs) and e2e-tests/generated/demo-navigation.spec.ts (sample output)
  • playwright.config.ts: HTML reporter; npm run test:e2e:report
  • Vitest/tsgo configs include scripts/; unit tests in generator.test.ts; README section

Testing

Data Layer Changes

  • Ran npm run test:unit - all tests pass
  • Added/updated Vitest tests for data-layer changes
  • Generated a migration (npm run db:generate) for any schema change

Frontend Changes

  • Ran npm run test:e2e - all tests pass
  • Added data-testid attributes to interactive elements
  • Verified build succeeds (npm run build)

Ran npm run typecheck (passes) and npm run test:generate -- e2e-tests/test-cases/demo-navigation.txt. test:unit, lint, build and test:e2e could not be run locally (missing native rolldown/astro bindings in my environment), so they are left unchecked and should be confirmed by CI.

Checklist

  • My code follows the project's coding standards
  • I have used explicit TypeScript types for function parameters and return values
  • I have built the UI with Astro components and Tailwind CSS utility classes (dark theme)
  • I have updated documentation (README, instruction files) if needed
  • My changes are focused on a single concern
  • I have written clear commit messages explaining what and why

Additional Notes

No new dependencies. The step format is Gherkin-like so it can later move to Cucumber.

Generates Playwright specs and step methods from plain-text steps, adds the HTML reporter, a demo test case and README docs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 06:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Stub names can collide with imports, JavaScript keywords, or fixtures and make generated specs unloadable, while suffix-only URL checks can falsely pass failed navigation.

2 open issues
What changed in this PR

Adds a dependency-free plain-steps generator to the existing Playwright test suite, addressing issue #184 and making E2E tests easier to author and inspect.

Changes:

  • Parses Gherkin-like steps into specs with reusable helpers, reportable steps, and failing stubs for unsupported actions.
  • Adds sample test cases, generated output, unit tests, and usage documentation.
  • Enables HTML reports and includes generator scripts in unit testing and type checking.
File Description
vitest.config.ts Includes script unit tests.
tsconfig.tsgo.json Includes scripts in type checking.
scripts/​test-generator/​generator.ts Implements parsing and spec generation.
scripts/​test-generator/​generator.test.ts Tests parsing, matching, generation, and slugs.
scripts/​test-generator/​cli.ts Reads test cases and writes generated specs.
README.md Documents generator usage and reports.
playwright.config.ts Enables HTML reports locally and in CI.
package.json Adds generation and report commands.
e2e-tests/​test-cases/​home-page.txt Provides a home-page smoke-test example.
e2e-tests/​test-cases/​demo-navigation.txt Provides navigation and unknown-page examples.
e2e-tests/​steps/​common-steps.ts Adds reusable actions and assertions.
e2e-tests/​generated/​demo-navigation.spec.ts Demonstrates generated tests with named steps.

Review effort: Balanced

Comment on lines +26 to +27
const escaped = path.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
await expect(page).toHaveURL(new RegExp(`${escaped}$`));
Comment on lines +113 to +114
let name = toCamelCase(step.text);
while (stubs.has(name) && stubs.get(name) !== step.text) name += '_';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a test-case generator that turns plain steps into Playwright specs, step methods and an HTML report

2 participants