cy2pw-cli
v1.0.0
Published
CLI tool to convert Cypress tests to Playwright
Downloads
6
Maintainers
Readme
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-cli2️⃣ 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/awaitsyntax for Playwright compatibility. - Converts all
.jsand.tstest 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 [email protected]: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! 🚀
