Repository navigation
Add plain-steps test case generator with Playwright HTML report - #198
Open
sanjeevkumarcspl wants to merge 1 commit into
Open
sanjeevkumarcspl wants to merge 1 commit into
sanjeevkumarcspl wants to merge 1 commit into
Conversation
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>
Contributor
There was a problem hiding this comment.
🟡 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 += '_'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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
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.tsandnpm run test:generate -- <steps-file>e2e-tests/steps/common-steps.ts: reusable step methodse2e-tests/test-cases/(sample inputs) ande2e-tests/generated/demo-navigation.spec.ts(sample output)playwright.config.ts: HTML reporter;npm run test:e2e:reportscripts/; unit tests ingenerator.test.ts; README sectionTesting
Data Layer Changes
npm run test:unit- all tests passnpm run db:generate) for any schema changeFrontend Changes
npm run test:e2e- all tests passdata-testidattributes to interactive elementsnpm run build)Ran
npm run typecheck(passes) andnpm run test:generate -- e2e-tests/test-cases/demo-navigation.txt.test:unit,lint,buildandtest:e2ecould not be run locally (missing native rolldown/astro bindings in my environment), so they are left unchecked and should be confirmed by CI.Checklist
Additional Notes
No new dependencies. The step format is Gherkin-like so it can later move to Cucumber.