@ash-mallick/browserstack-sync
v1.5.0
Published
Sync Playwright & Cypress e2e specs to CSV and BrowserStack Test Management with FREE AI-powered test step extraction using Ollama (local)
Maintainers
Readme
@ash-mallick/browserstack-sync
Sync 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
Install
npm install @ash-mallick/browserstack-syncOr run without installing: npx @ash-mallick/browserstack-sync --csv-only
Run
From your project root (where your e2e specs live):
# Generate CSVs only
npx am-browserstack-sync --csv-only
# Sync all specs, no prompt (e.g. CI)
npx am-browserstack-sync --all
# Sync only certain specs
npx am-browserstack-sync --spec=login.spec,checkout.spec
# Disable AI analysis (use regex extraction only)
npx am-browserstack-sync --no-ai
# Use a specific Ollama model
npx am-browserstack-sync --model=llama3.2Scripts in package.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:
// Your test code:
test('should log in successfully', async ({ page }) => {
await page.goto('/login');
await page.getByLabel(/email/i).fill('[email protected]');
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 '[email protected]' 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 |
Setup Ollama
Download and install Ollama from ollama.ai
Pull a model (llama3.2 recommended):
ollama pull llama3.2Start Ollama (runs automatically on macOS, or run manually):
ollama serveRun the sync — AI analysis is automatic when Ollama is running!
npx am-browserstack-sync --csv-only
Options
--no-ai— Disable AI, use regex-based extraction instead--model=llama3.2— Use a different Ollama modelOLLAMA_MODEL=llama3.2— Set default model via env variableOLLAMA_HOST=http://localhost:11434— Custom Ollama host
Recommended Models
| 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:
{
"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:
In project root, create
.env(do not commit):BROWSERSTACK_USERNAME=your_username BROWSERSTACK_ACCESS_KEY=your_access_key BROWSERSTACK_PROJECT_ID=PR-XXXXOr use a single token:
BROWSERSTACK_API_TOKEN=your_tokenGet credentials and project ID from Test Management → API keys. The project ID is in the project URL (e.g.
PR-1234).Install Ollama for AI-powered step analysis (optional but recommended).
Run
npx am-browserstack-sync(without--csv-only). You'll be prompted to sync all specs or pick specific ones (unless you use--allor--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, … - Analyzes test code with Ollama AI (local, free) or regex to generate human-readable steps and expected results.
- Enriches with state (Active), type (Functional), automation (automated), tags (from spec + title).
- Writes one CSV per spec (test_case_id, title, state, case_type, steps, expected_results, jira_issues, automation_status, tags, description, spec_file).
- Optionally syncs to BrowserStack with description, steps, and tags.
Author: Ashutosh Mallick
