1.0.0 ⢠Published 6 months ago
cy2pw-cli v1.0.0
cy2pw-cli
A command-line tool to migrate Cypress tests to Playwright, preserving directory structure and converting .js
& .ts
test files automatically.
š Features
ā
Converts Cypress .js
and .ts
test files to Playwright
ā
Preserves the original folder structure
ā
Supports custom source and target directories
ā
CLI-based, install once and use anywhere
ā
Error handling for missing directories
š„ Installation
1ļøā£ Global Installation (Recommended)
npm install -g cy2pw-cli
2ļøā£ Local Installation (Project-based)
npm install --save-dev cy2pw-cli
š Usage
š Convert Cypress Tests (Default Paths)
cy2pw-cli
(Default: ./cypress/integration
ā ./playwright/tests
)
š Convert with Custom Source & Target Directories
cy2pw-cli ./my-cypress-tests ./my-playwright-tests
š Help
cy2pw-cli --help
š§ How It Works
- Replaces Cypress commands (
cy.visit()
,cy.get()
, etc.) with Playwright equivalents. - Ensures
async/await
syntax for Playwright compatibility. - Converts all
.js
and.ts
test files while maintaining directory structure.
š Example
Before (Cypress Test)
describe('Login', () => {
it('should log in successfully', () => {
cy.visit('/login');
cy.get('#username').type('admin');
cy.get('#password').type('password');
cy.contains('Submit').click();
cy.get('.dashboard').should('be.visible');
});
});
After (Playwright Test)
test.describe('Login', async ({ page }) => {
test('should log in successfully', async ({ page }) => {
await page.goto('/login');
await page.locator('#username').fill('admin');
await page.locator('#password').fill('password');
await page.getByText('Submit').click();
await expect(page.locator('.dashboard')).toBeVisible();
});
});
š Development & Contributions
š§ Local Development
Clone the repo:
git clone git@github.com:arunchaitanyajami/cypress-to-playwright.git
cd cypress-to-playwright
npm install
š Link for Local Testing
npm link
cy2pw-cli ./cypress/integration ./playwright/tests
š¤ Publish to npm (For maintainers)
npm publish --access public
š License
MIT License. Feel free to contribute! š
1.0.0
6 months ago