Migrating from Cypress

Cypress tests are code full of selectors and waits. The same test in plain English is shorter, and the selectors and waits come from the first run's recording.

Coming There is no Cypress importer yet: automatic import is planned. Rewrite tests by hand, starting with the ones that break most; keep the rest running in Cypress meanwhile.

What maps to what

Cypress commands and the test-file equivalent
CypressIn a test file
describe / itone test per .test.md file, with name:
cy.visit("/pricing")start: /pricing, or a step Go to /pricing
cy.get("[data-cy=save]").click()Click "Save", or exactly: Exact: click testid=save
cy.get("#email").type(email)Fill "Email" with {{data.email}}
cy.contains("Saved")Expect: the page shows "Saved"
should("have.text", …)Expect: the page heading is "Welcome"
cy.url().should("include", "/dashboard")Expect: the URL contains /dashboard
Custom commandsflows (kind: flow), included with Use:
cy.session()an auth profile: auth: admin logs in once and reuses the saved session
fixturesdata:, plus {{unique.email}} for fresh values each run
Cypress.env(){{env.X}} for plain values, {{secret.X}} for credentials
baseUrl in cypress.configenvironments in optestra.config.yaml
cy.intercept()Coming Network mocking isn't available yet
cy.wait(2000)Nothing: waits are learned from the first run (lint warns about fixed waits)

A worked example

A Cypress spec with a cached login:

describe("projects", () => {
  it("saves a new project", () => {
    cy.session("ada", () => {
      cy.visit("/login");
      cy.get("#email").type("[email protected]");
      cy.get("#password").type(Cypress.env("SHOP_PASSWORD"), { log: false });
      cy.contains("button", "Log in").click();
    });
    cy.visit("/dashboard");
    cy.contains("button", "Create project").click();
    cy.get("[role=dialog]").should("contain", "New project");
    cy.get("#project-name").type("Q3 roadmap");
    cy.contains("button", "Create").click();
    cy.contains("Project created");
  });
});

The same test. The login becomes an auth profile named ada in the project file, pointing at a login flow, so it runs once and the session is reused:

---
name: A new project is saved
start: /dashboard
auth: ada
---

1. Click "Create project"
2. Expect: a dialog titled "New project" is open
3. Fill "Project name" with Q3 roadmap
4. Click "Create"
5. Expect: a message says "Project created"

See auth profiles and steps. Once recorded, the test is also a Playwright spec: Cypress to Playwright comes for free.