1.0.0 • Published 6 months ago

cy2pw-cli v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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