@ash-mallick/browserstack-sync 1.0.2 → 1.0.4
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 +10 -2
- package/lib/config.js +25 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,9 +49,17 @@ npx am-browserstack-sync --spec=login.spec,checkout.spec
|
|
|
49
49
|
|
|
50
50
|
## Config (optional)
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
**Auto-detection:** The tool automatically detects your e2e directory structure:
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
| Priority | Directory | CSV Output |
|
|
55
|
+
|----------|-----------|------------|
|
|
56
|
+
| 1st | `playwright/e2e` | `playwright/e2e-csv` |
|
|
57
|
+
| 2nd | `cypress/e2e` | `cypress/e2e-csv` |
|
|
58
|
+
| 3rd | `e2e` | `e2e-csv` |
|
|
59
|
+
|
|
60
|
+
No config needed for standard Playwright or Cypress projects!
|
|
61
|
+
|
|
62
|
+
**Override** via **`.am-browserstack-sync.json`** in project root:
|
|
55
63
|
|
|
56
64
|
```json
|
|
57
65
|
{
|
package/lib/config.js
CHANGED
|
@@ -11,19 +11,37 @@ const CONFIG_FILES = [
|
|
|
11
11
|
'.config/am-browserstack-sync.json',
|
|
12
12
|
];
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Auto-detect e2e directory based on common framework structures.
|
|
16
|
+
* Checks for existence in order: playwright/e2e, cypress/e2e, then fallback.
|
|
17
|
+
*/
|
|
18
|
+
function detectE2eDir(resolvedCwd) {
|
|
19
|
+
const candidates = [
|
|
20
|
+
{ e2eDir: 'playwright/e2e', csvOutputDir: 'playwright/e2e-csv' },
|
|
21
|
+
{ e2eDir: 'cypress/e2e', csvOutputDir: 'cypress/e2e-csv' },
|
|
22
|
+
{ e2eDir: 'e2e', csvOutputDir: 'e2e-csv' }, // Generic fallback
|
|
23
|
+
];
|
|
24
|
+
for (const candidate of candidates) {
|
|
25
|
+
const fullPath = path.join(resolvedCwd, candidate.e2eDir);
|
|
26
|
+
if (fs.existsSync(fullPath)) {
|
|
27
|
+
return candidate;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Default to playwright if nothing found (user will see "directory not found" error)
|
|
31
|
+
return { e2eDir: 'playwright/e2e', csvOutputDir: 'playwright/e2e-csv' };
|
|
32
|
+
}
|
|
18
33
|
|
|
19
34
|
/**
|
|
20
|
-
* Load config from cwd: env > config file > package.json field >
|
|
35
|
+
* Load config from cwd: env > config file > package.json field > auto-detect.
|
|
21
36
|
* Returns { cwd, e2eDir, csvOutputDir } (paths are absolute).
|
|
22
37
|
*/
|
|
23
38
|
export function loadConfig(cwd) {
|
|
24
39
|
const resolvedCwd = path.resolve(cwd || process.cwd());
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
|
|
41
|
+
// Auto-detect based on existing directory structure
|
|
42
|
+
const detected = detectE2eDir(resolvedCwd);
|
|
43
|
+
let e2eDir = detected.e2eDir;
|
|
44
|
+
let csvOutputDir = detected.csvOutputDir;
|
|
27
45
|
|
|
28
46
|
// package.json field
|
|
29
47
|
const pkgPath = path.join(resolvedCwd, 'package.json');
|
package/package.json
CHANGED