feat(adapters): generate Playwright specs from scaffold scenarios#79
Merged
Conversation
Render Playwright specs from NeutralScenario[], mirroring CypressE2EAdapter: a per-step action switch (navigate/click/type/assert-*/wait/api-call) maps to the Playwright API, wrapped in test.describe/test with the page fixture. Each GeneratedTest sets adapter=playwright, source=template, <slug>.spec.ts, and tests/<slug>.spec.ts. Unblocks scaffoldTests(url, { framework: 'playwright' }) and 'qulib scaffold --framework playwright', which previously threw 'Not implemented'.
Adds node:test coverage (9 tests) asserting real routes/selectors, quote escaping, target-less fallbacks, renderAll, and TypeScript-transpile syntactic validity; wired into the core test script.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Implements
PlaywrightAdapter, which was a not-implemented stub — bothrender()andrenderAll()threwError('Not implemented'). As a resultscaffoldTests(url, { framework: 'playwright' })andqulib scaffold --framework playwrightcould not generate any specs; onlycypress-e2eworked.The adapter now renders real Playwright specs from
NeutralScenario[], mirroring the structure of the workingCypressE2EAdapter(slugify→ per-steprenderStepswitch → spec template →renderAllmap). The factory andscaffold-tests.ts(buildPlaywrightProjectConfig) were already wired for'playwright', so only the renderer was missing.Action → Playwright API mapping
TestStep.actionnavigateawait page.goto(target)clickawait page.locator(target).click()typeawait page.locator(target).fill(value)assert-visibleawait expect(page.locator(target)).toBeVisible()(falls back tobody)assert-hiddenawait expect(page.locator(target)).toBeHidden()assert-text.toContainText(value)/.not.toBeEmpty()assert-disabledawait expect(page.locator(target)).toBeDisabled()assert-countexpect(await page.locator(target).count()).toBeGreaterThanOrEqual(n)waitawait page.waitForTimeout(n)api-callexpect((await page.request.get(url)).status()).toBe(200)Specs are wrapped in
import { test, expect } from '@playwright/test'+test.describe(...)/test(..., async ({ page }) => { ... }). EachGeneratedTestsetsadapter: 'playwright',source: 'template',filename: <slug>.spec.ts,outputPath: tests/<slug>.spec.ts.Sample output
Tests
New
node:testfile (src/adapters/__tests__/playwright-adapter.test.ts, 9 tests), wired into the coretestscript. Coverage: GeneratedTest metadata, the describe/test scaffold, every action rendering the real route/selector verbatim, embedded-quote escaping, target-less fallbacks/comments, the empty-steps placeholder,renderAll, andadapterType. Each rendered spec is validated as syntactically valid by transpiling it through the TypeScript compiler API (ts.transpileModulewithreportDiagnostics).Gates
npm run build(tsc): PASSnpm test(full core suite): PASS — 117/117, 0 fail (108 baseline + 9 new)🤖 Generated with Claude Code