Sync Playwright & Cypress e2e specs to CSV and BrowserStack Test Management with FREE AI-powered test step extraction using Ollama (local)
npm install @ash-mallick/browserstack-syncSync Playwright and Cypress e2e specs to CSV (TC-001, TC-002, …) and optionally to BrowserStack Test Management (one folder per spec, create/update test cases).
🦙 FREE AI-powered test step extraction using Ollama — runs 100% locally, no data sent to cloud!
By Ashutosh Mallick
---
``bash`
npm install @ash-mallick/browserstack-sync
Or run without installing: npx @ash-mallick/browserstack-sync --csv-only
---
From your project root (where your e2e specs live):
`bashGenerate CSVs only
npx am-browserstack-sync --csv-only
Scripts in
package.json:`json
{
"scripts": {
"sync:e2e": "am-browserstack-sync",
"sync:e2e-csv": "am-browserstack-sync --csv-only"
}
}
`---
🦙 AI-Powered Step Analysis (FREE with Ollama)
The tool uses Ollama to analyze your test code and generate human-readable test steps. Ollama runs 100% locally on your machine — no data sent to cloud, completely free, no API key needed!
Example transformation:
`typescript
// Your test code:
test('should log in successfully', async ({ page }) => {
await page.goto('/login');
await page.getByLabel(/email/i).fill('user@example.com');
await page.getByLabel(/password/i).fill('validpassword');
await page.getByRole('button', { name: /sign in/i }).click();
await expect(page).toHaveURL(/\/dashboard/);
});
`Generated steps:
| Step | Expected Result |
|------|-----------------|
| Navigate to /login page | Login page loads successfully |
| Enter 'user@example.com' in the Email field | Email is entered |
| Enter 'validpassword' in the Password field | Password is masked and entered |
| Click the 'Sign In' button | Form is submitted |
| Verify URL | URL matches /dashboard |
$3
1. Download and install Ollama from ollama.ai
2. Pull a model (llama3.2 recommended):
`bash
ollama pull llama3.2
`3. Start Ollama (runs automatically on macOS, or run manually):
`bash
ollama serve
`4. Run the sync — AI analysis is automatic when Ollama is running!
`bash
npx am-browserstack-sync --csv-only
`$3
-
--no-ai — Disable AI, use regex-based extraction instead
- --model=llama3.2 — Use a different Ollama model
- OLLAMA_MODEL=llama3.2 — Set default model via env variable
- OLLAMA_HOST=http://localhost:11434 — Custom Ollama host$3
| Model | Size | Best for |
|-------|------|----------|
|
llama3.2 | 2GB | General purpose, fast (default) |
| codellama | 4GB | Better code understanding |
| llama3.2:1b | 1GB | Fastest, lower quality |
| mistral | 4GB | Good balance |Fallback: If Ollama is not running, the tool automatically uses regex-based step extraction, which still provides meaningful steps.
---
Config (optional)
Defaults: e2e dir
playwright/e2e, CSV dir playwright/e2e-csv. For Cypress use e.g. cypress/e2e.Override via
.am-browserstack-sync.json in project root:`json
{
"e2eDir": "playwright/e2e",
"csvOutputDir": "playwright/e2e-csv"
}
`Or package.json:
"amBrowserstackSync": { "e2eDir": "...", "csvOutputDir": "..." }
Or env: PLAYWRIGHT_BROWSERSTACK_E2E_DIR, PLAYWRIGHT_BROWSERSTACK_CSV_DIR.---
BrowserStack sync
Sync pushes your e2e tests into BrowserStack Test Management so you can track test cases, link runs, and keep specs in sync with one source of truth. Under your chosen project it creates one folder per spec file (e.g.
login.spec, checkout.spec) and one test case per test, with title, description, steps, state (Active), type (Functional), automation status, and tags. Existing test cases are matched by title or TC-id and updated; new ones are created. No duplicates.Setup:
1. In project root, create
.env (do not commit):
`env
BROWSERSTACK_USERNAME=your_username
BROWSERSTACK_ACCESS_KEY=your_access_key
BROWSERSTACK_PROJECT_ID=PR-XXXX
`
Or use a single token: BROWSERSTACK_API_TOKEN=your_token2. Get credentials and project ID from Test Management → API keys. The project ID is in the project URL (e.g.
PR-1234).3. Install Ollama for AI-powered step analysis (optional but recommended).
4. Run
npx am-browserstack-sync (without --csv-only). You'll be prompted to sync all specs or pick specific ones (unless you use --all or --spec=...). After sync, open your project in BrowserStack to see the new folders and test cases.---
What it does
- Finds Playwright (
.spec., .test.) and Cypress (.cy.) spec files in your e2e dir.
- Extracts test titles from test('...') / it('...')`, assigns TC-001, TC-002, …Author: Ashutosh Mallick