@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.
Files changed (3) hide show
  1. package/README.md +10 -2
  2. package/lib/config.js +25 -7
  3. 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
- Defaults: e2e dir `playwright/e2e`, CSV dir `playwright/e2e-csv`. For Cypress use e.g. `cypress/e2e`.
52
+ **Auto-detection:** The tool automatically detects your e2e directory structure:
53
53
 
54
- Override via **`.am-browserstack-sync.json`** in project root:
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
- const DEFAULTS = {
15
- e2eDir: 'playwright/e2e',
16
- csvOutputDir: 'playwright/e2e-csv',
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 > defaults.
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
- let e2eDir = DEFAULTS.e2eDir;
26
- let csvOutputDir = DEFAULTS.csvOutputDir;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ash-mallick/browserstack-sync",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Sync Playwright & Cypress e2e specs to CSV and BrowserStack Test Management (one folder per spec)",
5
5
  "author": "Ashutosh Mallick",
6
6
  "type": "module",