testdriverai 5.2.2 → 5.3.0

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 (107) hide show
  1. package/.github/workflows/test-install.yml +1 -1
  2. package/README.md +5 -11
  3. package/agent.js +135 -99
  4. package/docs/30x30.mdx +84 -0
  5. package/docs/action/browser.mdx +129 -0
  6. package/docs/action/os.mdx +157 -0
  7. package/docs/action/output.mdx +98 -0
  8. package/docs/action/performance.mdx +71 -0
  9. package/docs/action/prerun.mdx +80 -0
  10. package/docs/action/secrets.mdx +103 -0
  11. package/docs/action/setup.mdx +115 -0
  12. package/docs/bugs/jira.mdx +208 -0
  13. package/docs/cli/overview.mdx +65 -0
  14. package/docs/commands/assert.mdx +31 -0
  15. package/docs/commands/exec.mdx +42 -0
  16. package/docs/commands/focus-application.mdx +29 -0
  17. package/docs/commands/hover-image.mdx +32 -0
  18. package/docs/commands/hover-text.mdx +37 -0
  19. package/docs/commands/if.mdx +43 -0
  20. package/docs/commands/match-image.mdx +41 -0
  21. package/docs/commands/press-keys.mdx +30 -0
  22. package/docs/commands/run.mdx +30 -0
  23. package/docs/commands/scroll-until-image.mdx +33 -0
  24. package/docs/commands/scroll-until-text.mdx +37 -0
  25. package/docs/commands/scroll.mdx +33 -0
  26. package/docs/commands/type.mdx +29 -0
  27. package/docs/commands/wait-for-image.mdx +31 -0
  28. package/docs/commands/wait-for-text.mdx +35 -0
  29. package/docs/commands/wait.mdx +30 -0
  30. package/docs/docs.json +226 -0
  31. package/docs/exporting/playwright.mdx +159 -0
  32. package/docs/features/auto-healing.mdx +124 -0
  33. package/docs/features/cross-platform.mdx +106 -0
  34. package/docs/features/generation.mdx +180 -0
  35. package/docs/features/github.mdx +161 -0
  36. package/docs/features/parallel-testing.mdx +130 -0
  37. package/docs/features/reusable-snippets.mdx +124 -0
  38. package/docs/features/selectorless.mdx +62 -0
  39. package/docs/features/visual-assertions.mdx +123 -0
  40. package/docs/getting-started/ci.mdx +196 -0
  41. package/docs/getting-started/generating.mdx +210 -0
  42. package/docs/getting-started/running.mdx +67 -0
  43. package/docs/getting-started/setup.mdx +133 -0
  44. package/docs/getting-started/writing.mdx +99 -0
  45. package/docs/guide/assertions.mdx +195 -0
  46. package/docs/guide/authentication.mdx +150 -0
  47. package/docs/guide/code.mdx +169 -0
  48. package/docs/guide/locating.mdx +136 -0
  49. package/docs/guide/setup-teardown.mdx +161 -0
  50. package/docs/guide/variables.mdx +218 -0
  51. package/docs/guide/waiting.mdx +199 -0
  52. package/docs/importing/csv.mdx +196 -0
  53. package/docs/importing/gherkin.mdx +142 -0
  54. package/docs/importing/jira.mdx +172 -0
  55. package/docs/importing/testrail.mdx +161 -0
  56. package/docs/integrations/electron.mdx +152 -0
  57. package/docs/integrations/netlify.mdx +98 -0
  58. package/docs/integrations/vercel.mdx +177 -0
  59. package/docs/interactive/assert.mdx +51 -0
  60. package/docs/interactive/generate.mdx +41 -0
  61. package/docs/interactive/run.mdx +36 -0
  62. package/docs/interactive/save.mdx +53 -0
  63. package/docs/interactive/undo.mdx +47 -0
  64. package/docs/issues.mdx +9 -0
  65. package/docs/overview/comparison.mdx +82 -0
  66. package/docs/overview/faq.mdx +122 -0
  67. package/docs/overview/quickstart.mdx +66 -0
  68. package/docs/overview/what-is-testdriver.mdx +73 -0
  69. package/docs/quickstart.mdx +66 -0
  70. package/docs/reference/commands/scroll.mdx +0 -0
  71. package/docs/reference/interactive/assert.mdx +0 -0
  72. package/docs/security/action.mdx +62 -0
  73. package/docs/security/agent.mdx +62 -0
  74. package/docs/security/dashboard.mdx +0 -0
  75. package/docs/security/platform.mdx +54 -0
  76. package/docs/tutorials/advanced-test.mdx +79 -0
  77. package/docs/tutorials/basic-test.mdx +41 -0
  78. package/electron/icon.png +0 -0
  79. package/electron/overlay.html +7 -3
  80. package/electron/overlay.js +75 -15
  81. package/electron/tray-buffered.png +0 -0
  82. package/electron/tray.png +0 -0
  83. package/index.js +75 -34
  84. package/lib/commander.js +22 -1
  85. package/lib/commands.js +87 -19
  86. package/lib/config.js +10 -1
  87. package/lib/focus-application.js +30 -23
  88. package/lib/generator.js +58 -7
  89. package/lib/init.js +48 -19
  90. package/lib/ipc.js +50 -0
  91. package/lib/logger.js +19 -6
  92. package/lib/overlay.js +82 -36
  93. package/lib/parser.js +9 -7
  94. package/lib/resources/prerun.yaml +17 -0
  95. package/lib/sandbox.js +2 -3
  96. package/lib/sdk.js +0 -2
  97. package/lib/session.js +3 -1
  98. package/lib/speak.js +0 -2
  99. package/lib/subimage/opencv.js +0 -4
  100. package/lib/system.js +56 -39
  101. package/lib/upload-secrets.js +65 -0
  102. package/lib/validation.js +175 -0
  103. package/package.json +2 -1
  104. package/postinstall.js +0 -24
  105. package/lib/websockets.js +0 -85
  106. package/test.md +0 -8
  107. package/test.yml +0 -18
@@ -0,0 +1,142 @@
1
+ ---
2
+ title: "Gherkin"
3
+ sidebarTitle: "Gherkin"
4
+ ---
5
+
6
+ This guide explains how to convert **Gherkin scenarios** into **TestDriver.ai prompts** for use in your testing workflows. By following this process, you can easily adapt existing Gherkin test cases into a format compatible with TestDriver.ai.
7
+
8
+ ---
9
+
10
+ ## What is Gherkin?
11
+
12
+ Gherkin is a plain-text language used to describe test scenarios in a human-readable format. It uses keywords like `Given`, `When`, `Then`, and `And` to define steps in a test.
13
+
14
+ ### Example Gherkin Scenario:
15
+
16
+ ```gherkin
17
+ Scenario: Successful login
18
+ Given the user is on the login page
19
+ When the user enters valid credentials
20
+ And clicks the "Log In" button
21
+ Then the user should see the dashboard
22
+ ```
23
+
24
+ ---
25
+
26
+ ## What Are TestDriver.ai Prompts?
27
+
28
+ TestDriver.ai prompts are high-level instructions that describe what the AI should do. They are written in plain text and focus on user actions or expected outcomes.
29
+
30
+ ### Example Prompts:
31
+
32
+ ```yaml
33
+ - prompt: the user is on the login page
34
+ - prompt: the user enters valid credentials
35
+ - prompt: clicks the "Log In" button
36
+ - prompt: the user should see the dashboard
37
+
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Steps to Convert Gherkin to TestDriver.ai Prompts
43
+
44
+ ### Step 1: Understand the Mapping
45
+
46
+ | **Gherkin Keyword** | **TestDriver.ai Prompt** |
47
+ |----------------------|----------------------------------------------|
48
+ | `Given` | Describes the initial state or setup. |
49
+ | `When` | Describes the user action. |
50
+ | `Then` | Describes the expected outcome or result. |
51
+ | `And` | Adds additional steps to the same context. |
52
+
53
+ ---
54
+
55
+ ### Step 2: Extract Steps from Gherkin
56
+
57
+ Take each step from the Gherkin scenario and rewrite it as a plain-text prompt. Remove the `Given`, `When`, `Then`, and `And` keywords, and focus on the action or expectation.
58
+
59
+ #### Example:
60
+
61
+ | **Gherkin Step** | **TestDriver.ai Prompt** |
62
+ |--------------------------------------|--------------------------------------|
63
+ | `Given the user is on the login page` | `the user is on the login page` |
64
+ | `When the user enters valid credentials` | `the user enters valid credentials` |
65
+ | `And clicks the "Log In" button` | `clicks the "Log In" button` |
66
+ | `Then the user should see the dashboard` | `the user should see the dashboard` |
67
+
68
+ ---
69
+
70
+ ### Step 3: Write the Prompts in YAML Format
71
+
72
+ Combine the extracted prompts into a YAML file. Each step should be written as a `prompt` entry.
73
+
74
+ #### Example YAML:
75
+
76
+ ```yaml
77
+ - prompt: the user is on the login page
78
+ - prompt: the user enters valid credentials
79
+ - prompt: clicks the "Log In" button
80
+ - prompt: the user should see the dashboard
81
+ ```
82
+
83
+ ---
84
+
85
+ ### Step 4: Save the YAML File
86
+
87
+ 1. Save the YAML content to a file (e.g., `login_test.yml`).
88
+ 2. Ensure the file is stored in the appropriate directory for your TestDriver.ai project (e.g., `testdriver/`).
89
+
90
+ ---
91
+
92
+ ### Step 5: Run the Test with TestDriver.ai
93
+
94
+ Use the TestDriver.ai CLI to execute the test.
95
+
96
+ #### Command:
97
+
98
+ ```bash
99
+ testdriverai run login_test.yml
100
+ ```
101
+
102
+ ---
103
+
104
+ ## Example: Full Conversion Workflow
105
+
106
+ ### Input Gherkin Scenario:
107
+
108
+ ```gherkin
109
+ Scenario: Add a product to the cart
110
+ Given the user is on the product page
111
+ When the user clicks "Add to Cart"
112
+ And confirms the action
113
+ Then the product should appear in the cart
114
+ ```
115
+
116
+ ### Converted YAML:
117
+
118
+ ```yaml
119
+ - prompt: the user is on the product page
120
+ - prompt: the user clicks "Add to Cart"
121
+ - prompt: confirms the action
122
+ - prompt: the product should appear in the cart
123
+ ```
124
+
125
+ ### Run the Test:
126
+
127
+ ```bash
128
+ testdriverai run add_to_cart_test.yml
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Best Practices
134
+
135
+ 1. **Keep Prompts Simple**: Focus on high-level actions or outcomes. Avoid including unnecessary details.
136
+ 2. **Use Descriptive Prompts**: Ensure each prompt clearly describes the action or expectation.
137
+ 3. **Test the YAML**: Run the converted YAML file to verify that it works as expected.
138
+ 4. **Organize Files**: Store YAML files in a structured directory (e.g., `testdriver/`) for easy management.
139
+
140
+ ---
141
+
142
+ By following this guide, you can efficiently convert Gherkin scenarios into TestDriver.ai prompts, enabling seamless integration of existing test cases into your TestDriver.ai workflows.
@@ -0,0 +1,172 @@
1
+ ---
2
+ title: "Jira"
3
+ sidebarTitle: "Jira"
4
+ ---
5
+
6
+ # Importing User Stories from Jira into TestDriver.ai Test Files
7
+
8
+ This guide explains how to extract **user stories** from Jira and convert them into **TestDriver.ai test files**. By automating this process, you can ensure that your user stories are directly translated into actionable test cases for TestDriver.ai.
9
+
10
+ ---
11
+
12
+ ## Workflow Overview
13
+
14
+ 1. **Export User Stories from Jira**: Use the Jira API to fetch user stories.
15
+ 2. **Convert User Stories to TestDriver.ai YAML**: Transform the user stories into YAML test files.
16
+ 3. **Save and Organize Test Files**: Store the generated YAML files in a structured directory.
17
+ 4. **Run Tests with TestDriver.ai**: Execute the tests using the TestDriver.ai CLI.
18
+
19
+ ---
20
+
21
+ ## Step 1: Export User Stories from Jira
22
+
23
+ ### Prerequisites
24
+ 1. **Jira API Token**: Generate an API token from your Jira account.
25
+ 2. **Jira Base URL**: Your Jira instance URL (e.g., `https://yourcompany.atlassian.net`).
26
+ 3. **Node.js**: Ensure Node.js is installed on your system.
27
+
28
+ ### Script: Export User Stories from Jira
29
+
30
+ The following script fetches Jira tickets and extracts the **user story title** and **acceptance criteria**.
31
+
32
+ #### Install Dependencies:
33
+
34
+ ```bash
35
+ npm install axios yaml fs
36
+ ```
37
+
38
+ #### Node.js Script (`export-jira-user-stories.js`):
39
+
40
+ ```javascript
41
+ const axios = require('axios');
42
+ const yaml = require('yaml');
43
+ const fs = require('fs');
44
+ const path = require('path');
45
+
46
+ // Jira credentials
47
+ const JIRA_BASE_URL = 'https://yourcompany.atlassian.net';
48
+ const JIRA_USERNAME = 'your-email@example.com';
49
+ const JIRA_API_TOKEN = 'your-api-token';
50
+ const JIRA_PROJECT_KEY = 'PROJECT_KEY'; // Replace with your Jira project key
51
+
52
+ // Output directory
53
+ const OUTPUT_DIR = './testdriver_tests';
54
+
55
+ // Ensure the output directory exists
56
+ if (!fs.existsSync(OUTPUT_DIR)) {
57
+ fs.mkdirSync(OUTPUT_DIR, { recursive: true });
58
+ }
59
+
60
+ // Fetch Jira tickets
61
+ async function fetchJiraTickets() {
62
+ try {
63
+ const response = await axios.get(
64
+ `${JIRA_BASE_URL}/rest/api/2/search?jql=project=${JIRA_PROJECT_KEY}`,
65
+ {
66
+ auth: {
67
+ username: JIRA_USERNAME,
68
+ password: JIRA_API_TOKEN,
69
+ },
70
+ headers: {
71
+ 'Content-Type': 'application/json',
72
+ },
73
+ }
74
+ );
75
+
76
+ const tickets = response.data.issues.map((issue) => ({
77
+ id: issue.key,
78
+ title: issue.fields.summary,
79
+ acceptanceCriteria: issue.fields.customfield_12345 || 'No acceptance criteria provided', // Replace `customfield_12345` with the field ID for "Acceptance Criteria"
80
+ }));
81
+
82
+ // Process each ticket
83
+ tickets.forEach((ticket) => createYamlFile(ticket));
84
+ console.log(`Exported ${tickets.length} user stories to ${OUTPUT_DIR}`);
85
+ } catch (error) {
86
+ console.error('Error fetching Jira tickets:', error.message);
87
+ }
88
+ }
89
+
90
+ // Create a YAML file for each user story
91
+ function createYamlFile(ticket) {
92
+ const steps = ticket.acceptanceCriteria
93
+ .split('\n')
94
+ .map((criteria) => ({
95
+ prompt: criteria.trim(),
96
+ }));
97
+
98
+ const yamlContent = {
99
+ version: '4.2.18',
100
+ steps,
101
+ };
102
+
103
+ const fileName = `${ticket.id}.yml`;
104
+ const filePath = path.join(OUTPUT_DIR, fileName);
105
+
106
+ fs.writeFileSync(filePath, yaml.stringify(yamlContent), 'utf8');
107
+ console.log(`Created file: ${filePath}`);
108
+ }
109
+
110
+ // Run the script
111
+ fetchJiraTickets();
112
+
113
+
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Step 2: Convert User Stories to TestDriver.ai YAML
119
+
120
+ The script above generates a YAML file for each Jira ticket. Each file contains the **acceptance criteria** as `prompt` entries.
121
+
122
+ ### Example YAML File (`testdriver_tests/PROJ-123.yml`):
123
+
124
+ ```yaml
125
+ version: 4.2.18
126
+ steps:
127
+ - prompt: The user can log in with valid credentials.
128
+ - prompt: An error message is displayed for invalid credentials.
129
+ - prompt: The login page is responsive on mobile devices.
130
+
131
+
132
+ ```---
133
+
134
+ ## Step 3: Save and Organize Test Files
135
+
136
+ 1. The generated YAML files will be saved in the `testdriver_tests/` directory.
137
+ 2. Ensure the directory is part of your TestDriver.ai project structure.
138
+
139
+ ---
140
+
141
+ ## Step 4: Run Tests with TestDriver.ai
142
+
143
+ Use the TestDriver.ai CLI to execute the generated test files.
144
+
145
+ ### Run a Single Test File:
146
+
147
+ ```bash
148
+ testdriverai run testdriver_tests/PROJ-123.yml
149
+
150
+
151
+ ```
152
+
153
+ ### Run All Test Files:
154
+
155
+ ```bash
156
+ testdriverai run testdriver_tests/*.yml
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Best Practices
162
+
163
+ 1. **Field Mapping**: Ensure the correct Jira field ID (e.g., `customfield_12345`) is used for "Acceptance Criteria."
164
+ 2. **Secure Credentials**: Store Jira API credentials in environment variables or secrets.
165
+ 3. **Review Generated Files**: Manually review the YAML files to ensure they align with your testing requirements.
166
+ 4. **Organize Tests**: Use a structured directory (e.g., `testdriver_tests/`) to manage your test files.
167
+
168
+ ---
169
+
170
+ ## Summary
171
+
172
+ By following this guide, you can automate the process of importing user stories from Jira into TestDriver.ai test files. This ensures that your acceptance criteria are directly translated into actionable tests, streamlining your testing workflows and improving coverage.
@@ -0,0 +1,161 @@
1
+ ---
2
+ title: "TestRail"
3
+ sidebarTitle: "TestRail"
4
+ ---
5
+
6
+ This guide explains how to extract **test cases** from TestRail and convert them into **TestDriver.ai YAML test files**. By automating this process, you can ensure that your TestRail test cases are directly translated into actionable tests for TestDriver.ai.
7
+
8
+ ---
9
+
10
+ ## Workflow Overview
11
+
12
+ 1. **Export Test Cases from TestRail**: Use the TestRail API to fetch test cases.
13
+ 2. **Convert Test Cases to TestDriver.ai YAML**: Transform the test cases into YAML test files.
14
+ 3. **Save and Organize Test Files**: Store the generated YAML files in a structured directory.
15
+ 4. **Run Tests with TestDriver.ai**: Execute the tests using the TestDriver.ai CLI.
16
+
17
+ ---
18
+
19
+ ## Step 1: Export Test Cases from TestRail
20
+
21
+ ### Prerequisites
22
+ 1. **TestRail API Key**: Obtain your API key from TestRail.
23
+ 2. **TestRail Base URL**: Your TestRail instance URL (e.g., `https://yourcompany.testrail.io`).
24
+ 3. **Node.js**: Ensure Node.js is installed on your system.
25
+
26
+ ### Script: Export Test Cases from TestRail
27
+
28
+ The following script fetches TestRail test cases and extracts the **title** and **steps**.
29
+
30
+ #### Install Dependencies:
31
+
32
+ ```bash
33
+ npm install axios yaml fs
34
+ ```
35
+
36
+ #### Node.js Script (`export-testrail-test-cases.js`):
37
+
38
+ ```javascript
39
+ const axios = require('axios');
40
+ const yaml = require('yaml');
41
+ const fs = require('fs');
42
+ const path = require('path');
43
+
44
+ // TestRail credentials
45
+ const TESTRAIL_BASE_URL = 'https://yourcompany.testrail.io';
46
+ const TESTRAIL_USERNAME = 'your-email@example.com';
47
+ const TESTRAIL_API_KEY = 'your-api-key';
48
+ const TESTRAIL_PROJECT_ID = 1; // Replace with your TestRail project ID
49
+
50
+ // Output directory
51
+ const OUTPUT_DIR = './testdriver_tests';
52
+
53
+ // Ensure the output directory exists
54
+ if (!fs.existsSync(OUTPUT_DIR)) {
55
+ fs.mkdirSync(OUTPUT_DIR, { recursive: true });
56
+ }
57
+
58
+ // Fetch TestRail test cases
59
+ async function fetchTestRailTestCases() {
60
+ try {
61
+ const response = await axios.get(
62
+ `${TESTRAIL_BASE_URL}/index.php?/api/v2/get_cases/${TESTRAIL_PROJECT_ID}`,
63
+ {
64
+ auth: {
65
+ username: TESTRAIL_USERNAME,
66
+ password: TESTRAIL_API_KEY,
67
+ },
68
+ headers: {
69
+ 'Content-Type': 'application/json',
70
+ },
71
+ }
72
+ );
73
+
74
+ const testCases = response.data.map((testCase) => ({
75
+ id: testCase.id,
76
+ title: testCase.title,
77
+ steps: testCase.custom_steps || 'No steps provided', // Replace `custom_steps` with the field ID for test steps if applicable
78
+ }));
79
+
80
+ // Process each test case
81
+ testCases.forEach((testCase) => createYamlFile(testCase));
82
+ console.log(`Exported ${testCases.length} test cases to ${OUTPUT_DIR}`);
83
+ } catch (error) {
84
+ console.error('Error fetching TestRail test cases:', error.message);
85
+ }
86
+ }
87
+
88
+ // Create a YAML file for each test case
89
+ function createYamlFile(testCase) {
90
+ const steps = testCase.steps
91
+ .split('\n')
92
+ .map((step) => ({
93
+ prompt: step.trim(),
94
+ }));
95
+
96
+ const yamlContent = {
97
+ version: '4.2.18',
98
+ steps,
99
+ };
100
+
101
+ const fileName = `test_${testCase.id}.yml`;
102
+ const filePath = path.join(OUTPUT_DIR, fileName);
103
+
104
+ fs.writeFileSync(filePath, yaml.stringify(yamlContent), 'utf8');
105
+ console.log(`Created file: ${filePath}`);
106
+ }
107
+
108
+ // Run the script
109
+ fetchTestRailTestCases();
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Step 2: Convert Test Cases to TestDriver.ai YAML
115
+
116
+ The script above generates a YAML file for each TestRail test case. Each file contains the **steps** as `prompt` entries.
117
+
118
+ ### Example YAML File (`testdriver_tests/test_123.yml`):
119
+
120
+ ```yaml
121
+ version: 4.2.18
122
+ steps:
123
+ - prompt: Navigate to the login page.
124
+ - prompt: Enter valid credentials.
125
+ - prompt: Click the "Log In" button.
126
+ - prompt: Verify the dashboard is displayed.
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Step 3: Save and Organize Test Files
132
+
133
+ 1. The generated YAML files will be saved in the `testdriver_tests/` directory.
134
+ 2. Ensure the directory is part of your TestDriver.ai project structure.
135
+
136
+ ---
137
+
138
+ ## Step 4: Run Tests with TestDriver.ai
139
+
140
+ Use the TestDriver.ai CLI to execute the generated test files.
141
+
142
+ ### Run a Single Test File:
143
+
144
+ ```bash
145
+ testdriverai run testdriver_tests/test_123.yml
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Best Practices
151
+
152
+ 1. **Field Mapping**: Ensure the correct TestRail field ID (e.g., `custom_steps`) is used for test steps.
153
+ 2. **Secure Credentials**: Store TestRail API credentials in environment variables or secrets.
154
+ 3. **Review Generated Files**: Manually review the YAML files to ensure they align with your testing requirements.
155
+ 4. **Organize Tests**: Use a structured directory (e.g., `testdriver_tests/`) to manage your test files.
156
+
157
+ ---
158
+
159
+ ## Summary
160
+
161
+ By following this guide, you can automate the process of importing test cases from TestRail into TestDriver.ai test files. This ensures that your test steps are directly translated into actionable tests, streamlining your testing workflows and improving coverage.
@@ -0,0 +1,152 @@
1
+ ---
2
+ title: "Electron"
3
+ ---
4
+
5
+ To integrate **TestDriver.ai** with a workflow that uses the **runner artifact URL** and **GitHub token** for downloading artifacts, you can modify the workflow to include these steps. Below is an example of how to adapt the workflow to ensure TestDriver.ai can access the artifacts.
6
+
7
+ ---
8
+
9
+ ## Updated Workflow with TestDriver.ai Integration
10
+
11
+ This workflow builds the application, uploads the build as an artifact, and then uses TestDriver.ai to download the artifact via the runner artifact URL and run tests.
12
+
13
+ ### Workflow File: `.github/workflows/testdriver-integration.yml````yaml
14
+ name: Build and Test with TestDriver.ai
15
+
16
+ on:
17
+ push:
18
+ branches:
19
+ - main
20
+ pull_request:
21
+ workflow_dispatch:
22
+
23
+ jobs:
24
+ build:
25
+ name: Build Application
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - name: Check out repository
29
+ uses: actions/checkout@v3
30
+
31
+ - name: Set up Node.js
32
+ uses: actions/setup-node@v3
33
+ with:
34
+ node-version: '16'
35
+
36
+ - name: Install dependencies
37
+ run: npm install
38
+
39
+ - name: Build Application
40
+ run: npm run build # Ensure your project has a build script
41
+
42
+ - name: Upload Build Artifact
43
+ uses: actions/upload-artifact@v3
44
+ with:
45
+ name: app-build
46
+ path: dist/ # Replace with the path to your built application
47
+
48
+ test:
49
+ name: Test Application with TestDriver.ai
50
+ runs-on: ubuntu-latest
51
+ needs: build
52
+ steps:
53
+ - name: Get Artifact URL
54
+ id: artifact-url
55
+ run: |
56
+ echo "ARTIFACT_URL=${{ github.server_url }}/repos/${{ github.repository }}/actions/artifacts" >> $GITHUB_ENV
57
+
58
+ - name: Run Tests with TestDriver.ai
59
+ uses: testdriverai/action@main
60
+ with:
61
+ key: ${{ secrets.TESTDRIVER_API_KEY }}
62
+ prompt: |
63
+ 1. Download the artifact from the runner URL
64
+ 2. Extract the artifact
65
+ 3. Run the application
66
+ 4. Verify the main window loads correctly
67
+ 5. Perform additional tests
68
+ prerun: |
69
+ echo "Downloading artifact..."
70
+ curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
71
+ -L "${{ env.ARTIFACT_URL }}" \
72
+ --output artifact.zip
73
+ echo "Extracting artifact..."
74
+ unzip artifact.zip -d ./app
75
+ echo "Running application..."
76
+ ./app/your-app-binary # Replace with the actual binary or executable path
77
+ env:
78
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79
+ FORCE_COLOR: "3"
80
+
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Key Changes and Explanation
86
+
87
+ ### 1. **Artifact URL Retrieval**
88
+ The `Get Artifact URL` step constructs the artifact URL dynamically using the GitHub repository and server URL. This ensures the TestDriver.ai runner can download the artifact.```yaml
89
+ - name: Get Artifact URL
90
+ id: artifact-url
91
+ run: |
92
+ echo "ARTIFACT_URL=${{ github.server_url }}/repos/${{ github.repository }}/actions/artifacts" >> $GITHUB_ENV
93
+
94
+ ```
95
+
96
+ ---
97
+
98
+ ### 2. **Downloading the Artifact**
99
+ The `prerun` script in the TestDriver.ai action uses `curl` to download the artifact from the runner URL. The `GITHUB_TOKEN` is passed as a header for authentication.```yaml
100
+ prerun: |
101
+ echo "Downloading artifact..."
102
+ curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
103
+ -L "${{ env.ARTIFACT_URL }}" \
104
+ --output artifact.zip
105
+ echo "Extracting artifact..."
106
+ unzip artifact.zip -d ./app
107
+ echo "Running application..."
108
+ ./app/your-app-binary # Replace with the actual binary or executable path
109
+
110
+ ```
111
+
112
+ ---
113
+
114
+ ### 3. **TestDriver.ai Integration**
115
+ The TestDriver.ai action is configured to:
116
+ - Download the artifact.
117
+ - Extract the artifact.
118
+ - Run the application.
119
+ - Execute the specified test steps.```yaml
120
+ - name: Run Tests with TestDriver.ai
121
+ uses: testdriverai/action@main
122
+ with:
123
+ key: ${{ secrets.TESTDRIVER_API_KEY }}
124
+ prompt: |
125
+ 1. Download the artifact from the runner URL
126
+ 2. Extract the artifact
127
+ 3. Run the application
128
+ 4. Verify the main window loads correctly
129
+ 5. Perform additional tests
130
+
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Secrets Configuration
136
+
137
+ Add the following secrets to your GitHub repository:
138
+ 1. **`TESTDRIVER_API_KEY`**: Your TestDriver.ai API key.
139
+ 2. **`GITHUB_TOKEN`**: Automatically provided by GitHub Actions for authentication.
140
+
141
+ ---
142
+
143
+ ## Benefits of This Workflow
144
+
145
+ 1. **Dynamic Artifact Access**: Ensures TestDriver.ai can download artifacts directly from the runner.
146
+ 2. **Automated Testing**: Integrates TestDriver.ai to validate the application after the build.
147
+ 3. **Secure Authentication**: Uses the GitHub token for secure artifact access.
148
+ 4. **Cross-Platform Support**: Can be adapted for different operating systems and environments.
149
+
150
+ ---
151
+
152
+ By integrating TestDriver.ai with the runner artifact URL and GitHub token, this workflow ensures seamless testing of your application builds.