@ash-mallick/browserstack-sync 1.0.5 → 1.0.6
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 +169 -45
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,122 +1,246 @@
|
|
|
1
1
|
# @ash-mallick/browserstack-sync
|
|
2
2
|
|
|
3
|
-
Sync **Playwright** and **Cypress** e2e specs to CSV
|
|
3
|
+
Sync **Playwright** and **Cypress** e2e test specs to CSV files and **BrowserStack Test Management**.
|
|
4
4
|
|
|
5
5
|
**By Ashutosh Mallick**
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## What It Does
|
|
10
|
+
|
|
11
|
+
- Scans your e2e test files (Playwright or Cypress)
|
|
12
|
+
- Extracts test cases and assigns IDs (TC-001, TC-002, ...)
|
|
13
|
+
- Generates **one CSV file per spec** with test details
|
|
14
|
+
- Optionally syncs to **BrowserStack Test Management** (creates folders and test cases)
|
|
15
|
+
- **Idempotent**: existing tests are updated, new ones are created (no duplicates)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
9
19
|
## Install
|
|
10
20
|
|
|
11
21
|
```bash
|
|
12
22
|
npm install @ash-mallick/browserstack-sync
|
|
13
23
|
```
|
|
14
24
|
|
|
15
|
-
Or run without installing:
|
|
25
|
+
Or run directly without installing:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx @ash-mallick/browserstack-sync --csv-only
|
|
29
|
+
```
|
|
16
30
|
|
|
17
31
|
---
|
|
18
32
|
|
|
19
|
-
##
|
|
33
|
+
## Usage
|
|
20
34
|
|
|
21
|
-
|
|
35
|
+
Run from your project root:
|
|
22
36
|
|
|
23
37
|
```bash
|
|
24
|
-
# Generate CSVs only
|
|
38
|
+
# Generate CSVs only (no BrowserStack sync)
|
|
25
39
|
npx am-browserstack-sync --csv-only
|
|
26
40
|
|
|
27
|
-
# Sync to BrowserStack (interactive
|
|
41
|
+
# Sync to BrowserStack (interactive prompt)
|
|
28
42
|
npx am-browserstack-sync
|
|
29
43
|
|
|
30
|
-
# Sync all specs
|
|
44
|
+
# Sync all specs without prompt (for CI/CD)
|
|
31
45
|
npx am-browserstack-sync --all
|
|
32
46
|
|
|
33
|
-
# Sync
|
|
47
|
+
# Sync specific specs only
|
|
34
48
|
npx am-browserstack-sync --spec=login.spec,checkout.spec
|
|
35
49
|
```
|
|
36
50
|
|
|
37
|
-
|
|
51
|
+
### Add to package.json scripts
|
|
38
52
|
|
|
39
53
|
```json
|
|
40
54
|
{
|
|
41
55
|
"scripts": {
|
|
42
56
|
"sync:e2e": "am-browserstack-sync",
|
|
43
|
-
"sync:
|
|
57
|
+
"sync:csv": "am-browserstack-sync --csv-only"
|
|
44
58
|
}
|
|
45
59
|
}
|
|
46
60
|
```
|
|
47
61
|
|
|
48
62
|
---
|
|
49
63
|
|
|
50
|
-
##
|
|
64
|
+
## Supported Frameworks
|
|
65
|
+
|
|
66
|
+
| Framework | File Patterns | Auto-Detected Directory |
|
|
67
|
+
|-----------|---------------|------------------------|
|
|
68
|
+
| Playwright | `*.spec.ts`, `*.spec.js`, `*.test.ts`, `*.test.js` | `playwright/e2e` |
|
|
69
|
+
| Cypress | `*.cy.ts`, `*.cy.js` | `cypress/e2e` |
|
|
70
|
+
| Generic | Any of the above | `e2e` |
|
|
71
|
+
|
|
72
|
+
**Auto-detection priority:**
|
|
73
|
+
1. `playwright/e2e` (if exists)
|
|
74
|
+
2. `cypress/e2e` (if exists)
|
|
75
|
+
3. `e2e` (generic fallback)
|
|
51
76
|
|
|
52
|
-
|
|
77
|
+
No configuration needed for standard project structures!
|
|
53
78
|
|
|
54
|
-
|
|
55
|
-
|----------|-----------|------------|
|
|
56
|
-
| 1st | `playwright/e2e` | `playwright/e2e-csv` |
|
|
57
|
-
| 2nd | `cypress/e2e` | `cypress/e2e-csv` |
|
|
58
|
-
| 3rd | `e2e` | `e2e-csv` |
|
|
79
|
+
---
|
|
59
80
|
|
|
60
|
-
|
|
81
|
+
## Configuration (Optional)
|
|
61
82
|
|
|
62
|
-
|
|
83
|
+
Override defaults via **`.am-browserstack-sync.json`** in project root:
|
|
63
84
|
|
|
64
85
|
```json
|
|
65
86
|
{
|
|
66
|
-
"e2eDir": "
|
|
67
|
-
"csvOutputDir": "
|
|
87
|
+
"e2eDir": "tests/e2e",
|
|
88
|
+
"csvOutputDir": "tests/csv-output"
|
|
68
89
|
}
|
|
69
90
|
```
|
|
70
91
|
|
|
71
|
-
Or **package.json**:
|
|
72
|
-
|
|
92
|
+
Or in **package.json**:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"amBrowserstackSync": {
|
|
97
|
+
"e2eDir": "cypress/e2e",
|
|
98
|
+
"csvOutputDir": "cypress/csv"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Or via **environment variables**:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
PLAYWRIGHT_BROWSERSTACK_E2E_DIR=tests/e2e
|
|
107
|
+
PLAYWRIGHT_BROWSERSTACK_CSV_DIR=tests/csv
|
|
108
|
+
```
|
|
73
109
|
|
|
74
110
|
---
|
|
75
111
|
|
|
76
|
-
## BrowserStack
|
|
112
|
+
## BrowserStack Integration
|
|
113
|
+
|
|
114
|
+
### Setup
|
|
115
|
+
|
|
116
|
+
1. Create a **`.env`** file in your project root (don't commit this!):
|
|
117
|
+
|
|
118
|
+
```env
|
|
119
|
+
BROWSERSTACK_USERNAME=your_username
|
|
120
|
+
BROWSERSTACK_ACCESS_KEY=your_access_key
|
|
121
|
+
BROWSERSTACK_PROJECT_ID=PR-XXXX
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Or use a single API token:
|
|
125
|
+
|
|
126
|
+
```env
|
|
127
|
+
BROWSERSTACK_API_TOKEN=your_token
|
|
128
|
+
BROWSERSTACK_PROJECT_ID=PR-XXXX
|
|
129
|
+
```
|
|
77
130
|
|
|
78
|
-
|
|
131
|
+
2. Get credentials from [BrowserStack Test Management → Settings → API Keys](https://test-management.browserstack.com/settings/api-keys)
|
|
79
132
|
|
|
80
|
-
|
|
133
|
+
3. Find your Project ID in the BrowserStack project URL (e.g., `PR-1234`)
|
|
81
134
|
|
|
82
|
-
|
|
135
|
+
### What Gets Synced
|
|
83
136
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
137
|
+
For each spec file, the tool:
|
|
138
|
+
- Creates a **folder** in BrowserStack (named after the spec file)
|
|
139
|
+
- Creates **test cases** with:
|
|
140
|
+
- Title (from test name)
|
|
141
|
+
- Description
|
|
142
|
+
- Steps and expected results
|
|
143
|
+
- State (Active)
|
|
144
|
+
- Type (Functional)
|
|
145
|
+
- Automation status (automated)
|
|
146
|
+
- Tags (framework, spec name, test keywords)
|
|
90
147
|
|
|
91
|
-
|
|
148
|
+
### Idempotent Sync
|
|
92
149
|
|
|
93
|
-
|
|
150
|
+
- **New tests** → Created in BrowserStack
|
|
151
|
+
- **Existing tests** (matched by title or TC-ID tag) → Updated
|
|
152
|
+
- **No duplicates** are created
|
|
94
153
|
|
|
95
154
|
---
|
|
96
155
|
|
|
97
|
-
##
|
|
156
|
+
## CSV Output
|
|
157
|
+
|
|
158
|
+
Each spec file generates a CSV with these columns:
|
|
98
159
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
160
|
+
| Column | Description |
|
|
161
|
+
|--------|-------------|
|
|
162
|
+
| `test_case_id` | TC-001, TC-002, ... |
|
|
163
|
+
| `title` | Test name |
|
|
164
|
+
| `state` | Active, Draft, etc. |
|
|
165
|
+
| `case_type` | Functional, Regression, etc. |
|
|
166
|
+
| `steps` | Test steps |
|
|
167
|
+
| `expected_results` | Expected outcomes |
|
|
168
|
+
| `jira_issues` | Linked Jira tickets |
|
|
169
|
+
| `automation_status` | automated / manual |
|
|
170
|
+
| `tags` | Framework, functionality tags |
|
|
171
|
+
| `description` | Test description |
|
|
172
|
+
| `spec_file` | Source file name |
|
|
104
173
|
|
|
105
174
|
---
|
|
106
175
|
|
|
107
176
|
## Programmatic API
|
|
108
177
|
|
|
109
|
-
|
|
178
|
+
Use in your own scripts:
|
|
179
|
+
|
|
180
|
+
```javascript
|
|
110
181
|
import { runSync } from '@ash-mallick/browserstack-sync';
|
|
111
182
|
|
|
112
183
|
await runSync({
|
|
113
184
|
cwd: '/path/to/project',
|
|
114
|
-
csvOnly:
|
|
185
|
+
csvOnly: false,
|
|
115
186
|
all: true,
|
|
116
|
-
|
|
187
|
+
// Or specify specific specs:
|
|
188
|
+
// spec: ['login.spec', 'checkout.spec'],
|
|
117
189
|
});
|
|
118
190
|
```
|
|
119
191
|
|
|
192
|
+
### Options
|
|
193
|
+
|
|
194
|
+
| Option | Type | Description |
|
|
195
|
+
|--------|------|-------------|
|
|
196
|
+
| `cwd` | string | Project root directory |
|
|
197
|
+
| `csvOnly` | boolean | Skip BrowserStack sync |
|
|
198
|
+
| `all` | boolean | Sync all specs (no prompt) |
|
|
199
|
+
| `spec` | string[] | Specific specs to sync |
|
|
200
|
+
| `e2eDir` | string | Override e2e directory |
|
|
201
|
+
| `csvOutputDir` | string | Override CSV output directory |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Example Project Structure
|
|
206
|
+
|
|
207
|
+
### Playwright
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
my-project/
|
|
211
|
+
├── package.json
|
|
212
|
+
├── .env # BrowserStack credentials
|
|
213
|
+
├── playwright/
|
|
214
|
+
│ ├── e2e/ # Your test files
|
|
215
|
+
│ │ ├── login.spec.ts
|
|
216
|
+
│ │ └── checkout.spec.ts
|
|
217
|
+
│ └── e2e-csv/ # Generated CSVs
|
|
218
|
+
│ ├── login.spec.csv
|
|
219
|
+
│ └── checkout.spec.csv
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Cypress
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
my-project/
|
|
226
|
+
├── package.json
|
|
227
|
+
├── .env
|
|
228
|
+
├── cypress/
|
|
229
|
+
│ ├── e2e/ # Your test files
|
|
230
|
+
│ │ ├── login.cy.ts
|
|
231
|
+
│ │ └── cart.cy.ts
|
|
232
|
+
│ └── e2e-csv/ # Generated CSVs
|
|
233
|
+
│ ├── login.cy.csv
|
|
234
|
+
│ └── cart.cy.csv
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
MIT
|
|
242
|
+
|
|
120
243
|
---
|
|
121
244
|
|
|
122
|
-
**Author:** Ashutosh Mallick
|
|
245
|
+
**Author:** Ashutosh Mallick
|
|
246
|
+
**npm:** [@ash-mallick/browserstack-sync](https://www.npmjs.com/package/@ash-mallick/browserstack-sync)
|
package/package.json
CHANGED