Skip to main content
Move one Playwright flow at a time, preserving its setup, actions, assertions, and cleanup. Momentic tests are YAML files with natural-language or CSS targets. Use a coding agent with the MCP server and coding agent skills to draft the files, then review them against the source spec before changing your CI gate.

Before and after

This example assumes a test shop, an empty cart, and a fresh authenticated state file generated by your existing Playwright setup. Both tests create an order; use a test account and isolate or reset its server-side data between runs.
checkout.spec.ts
The same user-flow checks in Momentic. This file sits at the repository root, so the auth path resolves to playwright/.auth/user.json:
checkout.test.yaml
Lint and run the new file alone. Start with whole-test retries disabled so a second attempt does not hide a setup or assertion mismatch:
authLoad refreshes the current page after restoring state. The following navigate makes the starting page explicit if unauthenticated navigation redirected to login. If you move the YAML under tests/, adjust the auth path relative to that file. YAML regex values are pattern strings, without JavaScript’s surrounding /.../ delimiters.

API mapping

Fixture and helper mapping

What keeps working unchanged

  • authLoad imports cookies and local storage from Playwright storage-state JSON. Keep your auth bootstrap running before the Momentic job and regenerate expired state. Keep state files out of Git. Playwright’s per-origin IndexedDB snapshot fields are not imported; validate any auth that depends on them separately.
  • A Node javascript step provides fetch, faker, and the documented JavaScript globals. Port seed endpoint calls into those steps. Existing helpers with imports or fixture dependencies need adaptation; you can keep them in a separate script before the CLI run.
  • Momentic installs and runs in the same GitHub Actions job; see Run in CI.
  • --reporter junit emits JUnit XML. Check the suite names, test names, and artifact paths expected by your existing analytics.

Preserve isolation and failure behavior

Momentic initializes a browser for each whole-test attempt. Put per-test setup in before and cleanup in after; teardown runs after setup or main-step failures, and a teardown failure fails the run. It cannot clean up a run that never reached setup, such as an initial navigation failure. Keep cleanup idempotent and use a separate cleanup job for shared server-side resources. Playwright worker fixtures and beforeAll are not equivalent to a Momentic module. Moving their contents into before repeats them on each test attempt. Keep shared services and seed data outside the test, or make per-test setup safe to repeat. Use separate accounts or unique records for concurrent tests that mutate server state. Preserve exact checks for URL, text, counts, and response fields. Use preset checks or JavaScript that throws when the condition fails; returning a value alone is not an assertion. Review any replacement AI assertion against the original expected state. Carry forward the role, accessible name, text matching rules, and scope of getByRole/getByText. Keep an explicit CSS target when a description cannot preserve those constraints. A visibility check does not replace an assertion about how many elements match. Compare whole-test retries, step retries, and failure recovery separately; passing after recovery does not establish first-attempt parity.

What does not map

  • Momentic re-resolves a target from its description each run (with a step cache to skip the model call when the page has not changed). Element handles and locator chains do not port: express the intent in the target text instead.
  • Firefox and WebKit projects have no equivalent browser target. Momentic web tests support Chromium-based browsers. Keep those existing browser jobs; --env selects deployment variables, not a browser engine or a project dependency graph.
  • Momentic manages the browser context, so browserContext control does not port. newTab, closeTab, and navigate cover tab workflows, but you do not create isolated contexts mid-test. Use separate tests or authLoad per test for different identities.
  • Custom page.on("console") event handlers do not port. Replace assertions that depend on them with explicit observable checks, or retain that coverage in Playwright.
  • The local editor and AI authoring cover what Codegen records; there is no recorder that emits Playwright-API code to copy back.

Incremental strategy

  1. Keep Playwright and its CI gate. Use the web setup to add Momentic, preserving an existing momentic.config.yaml. Commit the dependency lockfile and include globs that discover the new test files.
  2. Record each flow’s fixtures, test account, mocks, expected outcomes, browser variants, and cleanup. Port one critical flow and label it migrated.
  3. Lint it, then run it alone with --parallel 1 --retries 0. Confirm its assertions fail for a deliberate mismatch in your test environment, then restore the expected state. Review screenshots and any recovery or classification before accepting parity.
  4. Add a separate Momentic CI job with its own output directory and test data. Keep the Playwright job required while you compare results. Generate the auth file before the new job and make it available at the path the YAML expects. --filter selects a workspace project; it does not select a spec.
  5. Switch the gate flow by flow after repeated passes and a reviewed expected failure. Preserve the original specs and CI configuration in Git so you can restore the previous gate. Remove Playwright only after its remaining browser, fixture, and reporter coverage has a replacement.
Inspect the selected paths before running the overlap job:
By default, results check rejects non-quarantined runs that failed, were cancelled, recovered, or had a failure classification. It ignores quarantined runs and accepts an archive with zero tests. The recipe uses --ignore-quarantine so quarantine does not mask the selected tests’ statuses; confirm the list and run totals contain the enabled tests you intend to port. See results checks and GitHub Actions for CI setup.

Porting at scale with a coding agent

Point your coding agent at the spec files and the momentic-test skill. A prompt that works well:
Review the generated targets and assertions against the source spec, lint the YAML, and run each ported flow before replacing its existing CI gate.