@ash-mallick/browserstack-sync 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -132
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,46 +1,40 @@
|
|
|
1
1
|
# @ash-mallick/browserstack-sync
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
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).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**By Ashutosh Mallick**
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
### 1. Install
|
|
9
|
+
## Install
|
|
12
10
|
|
|
13
11
|
```bash
|
|
14
12
|
npm install @ash-mallick/browserstack-sync
|
|
15
|
-
# or run without installing
|
|
16
|
-
npx @ash-mallick/browserstack-sync --csv-only
|
|
17
13
|
```
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
Or run without installing: `npx @ash-mallick/browserstack-sync --csv-only`
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Run
|
|
20
20
|
|
|
21
|
-
From your
|
|
21
|
+
From your project root (where your e2e specs live):
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
#
|
|
24
|
+
# Generate CSVs only
|
|
25
25
|
npx am-browserstack-sync --csv-only
|
|
26
26
|
|
|
27
|
-
# Sync to BrowserStack
|
|
27
|
+
# Sync to BrowserStack (interactive: choose all or specific specs)
|
|
28
28
|
npx am-browserstack-sync
|
|
29
29
|
|
|
30
|
-
# Sync all specs
|
|
30
|
+
# Sync all specs, no prompt (e.g. CI)
|
|
31
31
|
npx am-browserstack-sync --all
|
|
32
32
|
|
|
33
|
-
# Sync only
|
|
34
|
-
npx am-browserstack-sync --spec=login.spec
|
|
33
|
+
# Sync only certain specs
|
|
35
34
|
npx am-browserstack-sync --spec=login.spec,checkout.spec
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- `npx am-browserstack-sync` (uses the bin name)
|
|
41
|
-
- `npx @ash-mallick/browserstack-sync` (runs the package)
|
|
42
|
-
|
|
43
|
-
Add scripts in your project’s `package.json`:
|
|
37
|
+
**Scripts** in `package.json`:
|
|
44
38
|
|
|
45
39
|
```json
|
|
46
40
|
{
|
|
@@ -51,22 +45,13 @@ Add scripts in your project’s `package.json`:
|
|
|
51
45
|
}
|
|
52
46
|
```
|
|
53
47
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### 3. Configure (optional)
|
|
57
|
-
|
|
58
|
-
Defaults:
|
|
59
|
-
|
|
60
|
-
- **E2E directory:** `playwright/e2e`
|
|
61
|
-
- **CSV output:** `playwright/e2e-csv`
|
|
62
|
-
|
|
63
|
-
For **Cypress**, set `e2eDir` to your specs folder (e.g. `cypress/e2e`, `cypress/integration`, or `cypress/specs`).
|
|
48
|
+
---
|
|
64
49
|
|
|
65
|
-
|
|
50
|
+
## Config (optional)
|
|
66
51
|
|
|
67
|
-
|
|
52
|
+
Defaults: e2e dir `playwright/e2e`, CSV dir `playwright/e2e-csv`. For Cypress use e.g. `cypress/e2e`.
|
|
68
53
|
|
|
69
|
-
|
|
54
|
+
Override via **`.am-browserstack-sync.json`** in project root:
|
|
70
55
|
|
|
71
56
|
```json
|
|
72
57
|
{
|
|
@@ -75,137 +60,55 @@ Create `.am-browserstack-sync.json` or `am-browserstack-sync.config.json`:
|
|
|
75
60
|
}
|
|
76
61
|
```
|
|
77
62
|
|
|
78
|
-
|
|
63
|
+
Or **package.json**: `"amBrowserstackSync": { "e2eDir": "...", "csvOutputDir": "..." }`
|
|
64
|
+
Or env: `PLAYWRIGHT_BROWSERSTACK_E2E_DIR`, `PLAYWRIGHT_BROWSERSTACK_CSV_DIR`.
|
|
79
65
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
```json
|
|
83
|
-
{
|
|
84
|
-
"amBrowserstackSync": {
|
|
85
|
-
"e2eDir": "tests/e2e",
|
|
86
|
-
"csvOutputDir": "tests/e2e-csv"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
(Legacy fields `amE2eSync`, `playwrightBrowserstackSync` are also supported.)
|
|
92
|
-
|
|
93
|
-
**C) Environment**
|
|
66
|
+
---
|
|
94
67
|
|
|
95
|
-
|
|
96
|
-
- `PLAYWRIGHT_BROWSERSTACK_CSV_DIR` – CSV output directory
|
|
68
|
+
## BrowserStack sync
|
|
97
69
|
|
|
98
|
-
|
|
70
|
+
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.
|
|
99
71
|
|
|
100
|
-
|
|
72
|
+
**Setup:**
|
|
101
73
|
|
|
102
|
-
1. In
|
|
74
|
+
1. In project root, create **`.env`** (do not commit):
|
|
103
75
|
|
|
104
76
|
```env
|
|
105
77
|
BROWSERSTACK_USERNAME=your_username
|
|
106
78
|
BROWSERSTACK_ACCESS_KEY=your_access_key
|
|
107
79
|
BROWSERSTACK_PROJECT_ID=PR-XXXX
|
|
108
80
|
```
|
|
109
|
-
|
|
110
81
|
Or use a single token: `BROWSERSTACK_API_TOKEN=your_token`
|
|
111
82
|
|
|
112
|
-
2. Get credentials and project ID from [
|
|
113
|
-
|
|
114
|
-
3. Run without `--csv-only`:
|
|
83
|
+
2. Get credentials and project ID from [Test Management → API keys](https://test-management.browserstack.com/settings/api-keys). The project ID is in the project URL (e.g. `PR-1234`).
|
|
115
84
|
|
|
116
|
-
|
|
117
|
-
npx am-browserstack-sync
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
The tool will:
|
|
121
|
-
|
|
122
|
-
- Create **one folder per spec file** under your project (e.g. `login.spec`, `checkout.spec`).
|
|
123
|
-
- **Create** test cases that don’t exist yet; **update** existing ones (matched by title or TC-id tag). No duplicates.
|
|
124
|
-
- When you change a test in the repo and run sync again, the corresponding test case on BrowserStack is updated.
|
|
85
|
+
3. 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.
|
|
125
86
|
|
|
126
87
|
---
|
|
127
88
|
|
|
128
89
|
## What it does
|
|
129
90
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
4. **Writes one CSV per spec** with columns: `test_case_id`, `title`, `state`, `case_type`, `steps`, `expected_results`, `jira_issues`, `automation_status`, `tags`, `description`, `spec_file`.
|
|
136
|
-
5. **Optionally** syncs to BrowserStack: creates folders, creates/updates test cases with description, steps, expected results, state, type, automation status, and tags.
|
|
137
|
-
|
|
138
|
-
### CSV columns and BrowserStack fields
|
|
139
|
-
|
|
140
|
-
| Column / field | Description | Default / example |
|
|
141
|
-
|----------------|-------------|-------------------|
|
|
142
|
-
| **title** | Test case title | From spec `test('...')` / `it('...')` |
|
|
143
|
-
| **state** | Lifecycle state | `Active` (or Draft, In Review, Outdated, Rejected) |
|
|
144
|
-
| **case_type** | Type of test | `Functional` (or Smoke & Sanity, Regression, etc.) |
|
|
145
|
-
| **steps** | Test steps with expected result | "Step 1: Run Playwright/Cypress e2e test \| Expected: See spec file..." |
|
|
146
|
-
| **expected_results** | Expected outcome | Filled from step results |
|
|
147
|
-
| **jira_issues** | Linked Jira keys | Empty (comma-separated in CSV) |
|
|
148
|
-
| **automation_status** | Automated or not | `automated` |
|
|
149
|
-
| **tags** | Functionality / labels | Inferred from spec name + title plus `playwright`/`cypress`, `e2e` |
|
|
150
|
-
| **description** | Test description | "Playwright/Cypress e2e test. ID: TC-001. [title]" |
|
|
91
|
+
- Finds **Playwright** (`*.spec.*`, `*.test.*`) and **Cypress** (`*.cy.*`) spec files in your e2e dir.
|
|
92
|
+
- Extracts test titles from `test('...')` / `it('...')`, assigns TC-001, TC-002, …
|
|
93
|
+
- Enriches with state (Active), type (Functional), automation (automated), tags (from spec + title).
|
|
94
|
+
- Writes **one CSV per spec** (test_case_id, title, state, case_type, steps, expected_results, jira_issues, automation_status, tags, description, spec_file).
|
|
95
|
+
- Optionally syncs to BrowserStack with description, steps, and tags.
|
|
151
96
|
|
|
152
97
|
---
|
|
153
98
|
|
|
154
99
|
## Programmatic API
|
|
155
100
|
|
|
156
|
-
You can import the package and call `runSync` from your own scripts:
|
|
157
|
-
|
|
158
101
|
```js
|
|
159
102
|
import { runSync } from '@ash-mallick/browserstack-sync';
|
|
160
103
|
|
|
161
104
|
await runSync({
|
|
162
|
-
cwd: '/path/to/
|
|
105
|
+
cwd: '/path/to/project',
|
|
163
106
|
csvOnly: true,
|
|
164
|
-
all: true,
|
|
165
|
-
spec: ['login.spec'],
|
|
166
|
-
// optional: e2eDir, csvOutputDir, auth: { username, accessKey, projectId },
|
|
107
|
+
all: true,
|
|
108
|
+
spec: ['login.spec'],
|
|
167
109
|
});
|
|
168
110
|
```
|
|
169
111
|
|
|
170
112
|
---
|
|
171
113
|
|
|
172
|
-
## Publishing this package
|
|
173
|
-
|
|
174
|
-
1. **Package name** is `@ash-mallick/browserstack-sync`. The CLI command is **`am-browserstack-sync`**.
|
|
175
|
-
|
|
176
|
-
2. **Set repository URL** in `package.json` (optional):
|
|
177
|
-
```json
|
|
178
|
-
"repository": { "type": "git", "url": "https://github.com/ash-mallick/browserstack-sync" }
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
3. **Publish to npm:**
|
|
182
|
-
```bash
|
|
183
|
-
npm login
|
|
184
|
-
npm publish --access public
|
|
185
|
-
```
|
|
186
|
-
(Scoped packages require `--access public` for public installs.)
|
|
187
|
-
|
|
188
|
-
4. **Use it in another project:**
|
|
189
|
-
```bash
|
|
190
|
-
npm install @ash-mallick/browserstack-sync
|
|
191
|
-
npx am-browserstack-sync --csv-only
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
## This repo as a demo
|
|
197
|
-
|
|
198
|
-
This repository is the package source and includes sample specs under `playwright/e2e/`. To run the sync **in this repo**:
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
npm install
|
|
202
|
-
npm run sync:csv-only
|
|
203
|
-
# or with .env set:
|
|
204
|
-
npm run sync:csv
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
CSVs are written to `playwright/e2e-csv/`.
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
114
|
**Author:** Ashutosh Mallick
|
package/package.json
CHANGED