{"_id":"@camppp/cypress-to-playwright","name":"@camppp/cypress-to-playwright","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.5":{"name":"@camppp/cypress-to-playwright","version":"1.0.5","description":"Translates Cypress commands to Playwright equivalents at runtime","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./globals":{"types":"./dist/src/globals.d.ts"}},"publishConfig":{"access":"public"},"engines":{"node":">=18.0.0"},"scripts":{"build":"tsc","dev":"tsc --watch","test":"jest","test:playwright":"playwright test"},"keywords":["cypress","playwright","testing","command-translation","migration","e2e"],"repository":{"type":"git","url":"git+https://github.com/camppp/cypress-to-playwright.git"},"bugs":{"url":"https://github.com/camppp/cypress-to-playwright/issues"},"homepage":"https://github.com/camppp/cypress-to-playwright#readme","author":"","license":"MIT","peerDependencies":{"@playwright/test":">=1.40.0"},"devDependencies":{"@types/chai":"^5.2.3","@types/jest":"^29.0.0","@types/node":"^20.0.0","chai":"^6.2.2","cypress":"^15.13.0","jest":"^29.0.0","ts-jest":"^29.0.0","typescript":"^5.0.0"},"dependencies":{"@playwright/test":"^1.40.0","idb-keyval":"^6.2.2"},"_id":"@camppp/cypress-to-playwright@1.0.5","gitHead":"a35527103ca8e2380ffae89ca2cfb128316c67df","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-rGvGDyTl6zxLhPq1eLwiZWlkW1p5eXxljxmybaAhkc3GSJ3kBQkOLkZXHiOy5QN5vePrFKlRDOQifzgsE/tJxA==","shasum":"97f74aadef11c5281acfd9fceadf823d93520ede","tarball":"https://registry.npmjs.org/@camppp/cypress-to-playwright/-/cypress-to-playwright-1.0.5.tgz","fileCount":69,"unpackedSize":191169,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDkUVObTIfUxD3aQ+dzVSX4ZHbHcOdHAfd/T9p8MdMNWAIgGkvNFZZ0AfksP79BqRZ3HciCLxppR9/FfD59uMo9CkA="}]},"_npmUser":{"name":"camppp","email":"lyuxuan0422@gmail.com"},"directories":{},"maintainers":[{"name":"camppp","email":"lyuxuan0422@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cypress-to-playwright_1.0.5_1777493650016_0.8358992273585264"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-29T20:14:09.736Z","1.0.5":"2026-04-29T20:14:10.191Z","modified":"2026-04-29T20:14:10.411Z"},"maintainers":[{"name":"camppp","email":"lyuxuan0422@gmail.com"}],"description":"Translates Cypress commands to Playwright equivalents at runtime","homepage":"https://github.com/camppp/cypress-to-playwright#readme","keywords":["cypress","playwright","testing","command-translation","migration","e2e"],"repository":{"type":"git","url":"git+https://github.com/camppp/cypress-to-playwright.git"},"bugs":{"url":"https://github.com/camppp/cypress-to-playwright/issues"},"license":"MIT","readme":"# cypress-to-playwright\n\nA package that translates Cypress commands to Playwright equivalents at runtime. When imported, it provides a proxy that intercepts Cypress-style commands and executes them using Playwright's API.\n\n> **Why?** Because enterprise migration consultants charge six figures to tell you to rewrite everything. This does it for you, automatically, at runtime — and yes, I built it for the memes. But it works. Seriously. Production-grade, fully typed, 103 integration tests passing, ready for `npm publish`. The memes just happened to be serious.\n\n## Installation\n\n```bash\nnpm install @camppp/cypress-to-playwright\n```\n\n## Usage\n\n### New Playwright tests, Cypress-style commands\n\n```typescript\nimport { setupCypressToPlaywright } from '@camppp/cypress-to-playwright';\nimport { test, expect } from '@playwright/test';\n\ntest('example', async ({ page }) => {\n  const cy = setupCypressToPlaywright(page);\n\n  // Now use Cypress-style commands\n  await cy.visit('https://example.com');\n  await cy.get('button').click();\n  await cy.get('input').type('hello');\n});\n```\n\n### Existing Cypress specs — zero rewrites\n\nIf you already have a `cypress/` directory full of `*.spec.ts` files using `describe`, `it`, `cy.visit`, `cy.get`, etc., you can run them under Playwright without modifying a single test file.\n\nAdd this to your `playwright.config.ts`:\n\n```typescript\nimport { defineConfig } from '@playwright/test';\nimport { setupCypressGlobals } from '@camppp/cypress-to-playwright';\n\nsetupCypressGlobals(); // Injects cy, describe, it, expect, Cypress into globalThis\n\nexport default defineConfig({\n  testDir: './cypress', // or wherever your specs live\n});\n```\n\nThen add this triple-slash directive at the top of any spec file that TypeScript complains about (or add it to a single `.d.ts` file in your project):\n\n```typescript\n/// <reference types=\"@camppp/cypress-to-playwright/globals\" />\n```\n\nYour existing spec files will just work:\n\n```typescript\ndescribe('Login', () => {\n  it('should log in', () => {\n    cy.visit('/login');\n    cy.get('[data-testid=email]').type('user@example.com');\n    cy.get('button').click();\n    cy.url().should('include', '/dashboard');\n  });\n});\n```\n\n## Supported Cypress Commands\n\n- **Navigation**: `visit`, `reload`, `go`, `url`, `title`, `window`, `viewport`, `log`\n- **Selection**: `get`, `contains`, `find`, `findByTestId`, `findAllByTestId`, `document`\n- **Interaction**: `click`, `type`, `clear`, `check`, `uncheck`, `select`, `hover`, `rightclick`, `dblclick`, `focus`, `blur`, `submit`, `trigger`\n- **Scrolling**: `scrollIntoView`, `scrollTo`\n- **Traversal**: `parent`, `children`, `siblings`, `closest`, `next`, `prev`, `nextAll`, `prevAll`, `parents`, `parentsUntil`, `eq`, `first`, `last`, `filter`, `not`, `is`, `has`\n- **Assertions**: `should`, `and` — supports `eq`, `equal`, `eql`, `exist`, `visible`, `hidden`, `enabled`, `disabled`, `checked`, `selected`, `empty`, `focus`, `have.class`, `have.text`, `have.value`, `have.attr`, `have.prop`, `have.css`, `have.html`, `have.id`, `have.length`, `have.descendants`, `contain`, `include`, `match`, `gt`, `gte`, `lt`, `lte`, `within`, `closeTo`, `oneOf`, `instanceOf`, `keys`, `above`, `below`, `members`, `satisfy`, `a`, `an`, `true`, `false`, `null`, `undefined`, `NaN`, `ok`, `truthy`, `deep.equal`\n- **Network**: `intercept`, `as`, `request`\n- **Scope**: `within`, `resetWithinScope`\n- **Properties**: `its`, `invoke`, `wrap`, `config`, `prop`, `hasClass`, `length`\n- **Utilities**: `wait`, `screenshot`, `then`, `each`\n\n## Supported Mocha Functions\n\nThe package also translates Mocha test structure functions to Playwright equivalents:\n\n- `describe(name, callback)` - Test suite grouping\n- `context(name, callback)` - Alias for describe\n- `it(name, callback)` - Individual test case\n- `before(callback)` - Setup before all tests\n- `after(callback)` - Teardown after all tests\n- `beforeEach(callback)` - Setup before each test\n- `afterEach(callback)` - Teardown after each test\n\n### Example with Mocha\n\n```typescript\nimport { describe, context, it, beforeEach, afterEach, setupCypressToPlaywright } from '@camppp/cypress-to-playwright';\nimport { expect } from '@playwright/test';\nimport { chromium } from '@playwright/test';\n\ndescribe('My Test Suite', () => {\n  let browser: any;\n  let page: any;\n  let cy: any;\n\n  beforeEach(async () => {\n    browser = await chromium.launch();\n    page = await browser.newPage();\n    cy = setupCypressToPlaywright(page);\n  });\n\n  afterEach(async () => {\n    if (browser) await browser.close();\n  });\n\n  context('Navigation', () => {\n    it('should visit a page', async () => {\n      await cy.visit('https://example.com');\n      const title = await page.title();\n      expect(title).toContain('Example');\n    });\n  });\n});\n```\n\n## Project Structure\n\n```\nsrc/\n├── index.ts                    # Main entry point\n├── cypress-translator.ts       # Re-exports the composed translator\n├── proxy.ts                    # Proxy handler for command interception\n├── mocha-translator.ts         # Mocha test structure translation\n├── setup-globals.ts            # Injects cy, describe, it, expect, Cypress into globalThis\n├── globals.d.ts                # Ambient type declarations for injected globals\n└── translators/\n    ├── base.ts                 # Shared state and utilities\n    ├── navigation.ts           # visit, reload, go, url, title\n    ├── interaction.ts          # click, type, clear, check, trigger\n    ├── selection.ts            # get, contains, find\n    ├── traversal.ts            # parent, children, siblings, closest, filter\n    ├── assertions.ts           # should, and assertion chains\n    ├── properties.ts           # its, invoke, wrap, config\n    ├── network.ts              # intercept, as, request\n    ├── scope.ts                # within scoping\n    └── types.ts              # Cypress-compatible type definitions\n```\n\n## Development\n\n```bash\nnpm install\nnpm run build      # Build the project\nnpm run dev        # Watch mode\nnpm test           # Run unit tests\nnpm run test:playwright  # Run integration tests\n```\n\n## Requirements\n\n- Node.js >= 18.0.0\n- `@playwright/test` >= 1.40.0 (peer dependency)\n","readmeFilename":"README.md","_rev":"1-d1b18e36d46d2f799c0699fc79e6e1d0"}