-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathconfig-generator.ts
More file actions
98 lines (84 loc) · 3.03 KB
/
config-generator.ts
File metadata and controls
98 lines (84 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Configuration utilities for BrowserStack App SDK
import {
APP_DEVICE_CONFIGS,
AppSDKSupportedTestingFrameworkEnum,
DEFAULT_APP_PATH,
createStep,
} from "./index.js";
export function generateAppBrowserStackYMLInstructions(
platforms: string[],
username: string,
accessKey: string,
appPath: string = DEFAULT_APP_PATH,
testingFramework: string,
): string {
if (
testingFramework === AppSDKSupportedTestingFrameworkEnum.nightwatch ||
testingFramework === AppSDKSupportedTestingFrameworkEnum.webdriverio ||
testingFramework === AppSDKSupportedTestingFrameworkEnum.cucumberRuby
) {
return "";
}
// Generate platform and device configurations
const platformConfigs = platforms
.map((platform) => {
const devices =
APP_DEVICE_CONFIGS[platform as keyof typeof APP_DEVICE_CONFIGS];
if (!devices) return "";
return devices
.map(
(device) => ` - platformName: ${platform}
deviceName: ${device.deviceName}
platformVersion: "${device.platformVersion}"`,
)
.join("\n");
})
.filter(Boolean)
.join("\n");
// Construct YAML content
const configContent = `\`\`\`yaml
userName: ${username}
accessKey: ${accessKey}
app: ${appPath}
platforms:
${platformConfigs}
# Parallels per Platform
# Default: 1
parallelsPerPlatform: 1
# Local Testing
# Set to true if you need to test apps with local/staging servers
# Default: false
browserstackLocal: true
# Project and build names help organize your test runs in BrowserStack dashboard and Percy.
# TODO: Replace these sample values with your actual project details
buildName: bstack-demo
projectName: BrowserStack Sample
# Debugging features
# debug: Provides screenshots and logs (Default: true)
# networkLogs: Capture API/network traffic (Default: false)
debug: true
networkLogs: true
# Percy Visual Testing (Default: false)
percy: false
percyCaptureMode: auto
# Accessibility Testing (Default: false)
accessibility: false
# Optional settings (uncomment only if explicitly required)
# geoLocation: "US" # Simulate tests from a specific region
# timezone: "New_York" # Run tests in a custom timezone
# retryOnFailure: 2 # Retries failed tests (Default: 0)
# idleTimeout: 30 # Max idle time in seconds (Default: 30, Range: 0-300)
# commandTimeout: 180 # Max time to wait for a command (Default: 180)
# deviceOrientation: portrait # For mobile, choose portrait or landscape (Default: portrait)
\`\`\`
**Important notes:**
- Replace \`app: ${appPath}\` with the path to your actual app file (e.g., \`./SampleApp.apk\` for Android or \`./SampleApp.ipa\` for iOS).
- You can upload your app using BrowserStack's App Upload API or manually through the dashboard.
- Adjust \`parallelsPerPlatform\` based on your subscription limits`;
// Return formatted step for instructions
return createStep(
"Update browserstack.yml file with App Automate configuration:",
`Create or update the browserstack.yml file in your project root with the following content:
${configContent}`,
);
}