testdriverai 7.2.34 → 7.2.36
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/docs/v7/aws-setup.mdx
CHANGED
|
@@ -13,6 +13,18 @@ graph LR
|
|
|
13
13
|
B <--> C[Your AWS EC2 Instance]
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
# Quickstart
|
|
17
|
+
|
|
18
|
+
<Card
|
|
19
|
+
title="Launch Stack"
|
|
20
|
+
icon="aws"
|
|
21
|
+
href="https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?templateURL=https://v7-cloudformation-template.s3.us-east-2.amazonaws.com/cloudformation.yaml"
|
|
22
|
+
horizontal
|
|
23
|
+
arrow
|
|
24
|
+
>
|
|
25
|
+
Deploy TestDriver infrastructure with one click
|
|
26
|
+
</Card>
|
|
27
|
+
|
|
16
28
|
## Overview
|
|
17
29
|
|
|
18
30
|
The setup process involves three main steps:
|
|
@@ -21,6 +33,7 @@ The setup process involves three main steps:
|
|
|
21
33
|
2. **On-Demand Instance Spawning** — Use `spawn-runner.sh` to launch TestDriver instances when you need to run tests
|
|
22
34
|
3. **CI/CD Integration** — Automate the lifecycle in GitHub Actions: spawn instance → run tests → terminate instance
|
|
23
35
|
|
|
36
|
+
|
|
24
37
|
## Prerequisites
|
|
25
38
|
|
|
26
39
|
Before you begin, ensure you have:
|
|
@@ -31,7 +44,7 @@ Before you begin, ensure you have:
|
|
|
31
44
|
- A GitHub repository for your tests
|
|
32
45
|
|
|
33
46
|
<Tip>
|
|
34
|
-
The TestDriver Golden Image AMI ID is `ami-
|
|
47
|
+
The TestDriver Golden Image AMI ID is `ami-0504bf50fad62f312`. Contact us to get access in your preferred AWS region.
|
|
35
48
|
</Tip>
|
|
36
49
|
|
|
37
50
|
## Step 1: Deploy CloudFormation Stack
|
|
@@ -43,57 +56,88 @@ Our CloudFormation template creates all the AWS infrastructure you need:
|
|
|
43
56
|
- IAM roles and instance profiles
|
|
44
57
|
- EC2 launch template for instance creation
|
|
45
58
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
<Tabs>
|
|
60
|
+
<Tab title="GUI">
|
|
61
|
+
Click the button below to launch the CloudFormation stack in your AWS Console:
|
|
62
|
+
|
|
63
|
+
<Card
|
|
64
|
+
title="Launch Stack"
|
|
65
|
+
icon="aws"
|
|
66
|
+
href="https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?templateURL=https://v7-cloudformation-template.s3.us-east-2.amazonaws.com/cloudformation.yaml"
|
|
67
|
+
horizontal
|
|
68
|
+
arrow
|
|
69
|
+
>
|
|
70
|
+
Deploy TestDriver infrastructure with one click
|
|
71
|
+
</Card>
|
|
72
|
+
|
|
73
|
+
Configure the stack parameters:
|
|
74
|
+
- **Stack name**: `testdriver-infrastructure` (or your preferred name)
|
|
75
|
+
- **ProjectTag**: `testdriver`
|
|
76
|
+
- **AllowedIngressCidr**: Your IP range (e.g., `203.0.113.0/24`)
|
|
77
|
+
- **InstanceType**: `c5.xlarge` (recommended)
|
|
78
|
+
- **CreateKeyPair**: `true`
|
|
79
|
+
|
|
80
|
+
<Warning>
|
|
81
|
+
**Security**: Replace `AllowedIngressCidr` with your specific IP ranges to restrict VPC access. Avoid using `0.0.0.0/0` in production.
|
|
82
|
+
</Warning>
|
|
83
|
+
|
|
84
|
+
### Get Your Launch Template ID
|
|
85
|
+
|
|
86
|
+
After the stack creation completes, navigate to the **Outputs** tab to find your `LaunchTemplateId`:
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
|
|
90
|
+
<Tip>
|
|
91
|
+
**Save this ID** — you'll need it for spawning instances and CI configuration.
|
|
92
|
+
</Tip>
|
|
93
|
+
</Tab>
|
|
94
|
+
<Tab title="CLI">
|
|
95
|
+
Download the template from the [TestDriver CLI repository](https://github.com/testdriverai/testdriverai/blob/main/setup/aws/cloudformation.yaml), then deploy:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
aws cloudformation deploy \
|
|
99
|
+
--template-file setup/aws/cloudformation.yaml \
|
|
100
|
+
--stack-name testdriver-infrastructure \
|
|
101
|
+
--parameter-overrides \
|
|
102
|
+
ProjectTag=testdriver \
|
|
103
|
+
AllowedIngressCidr=0.0.0.0/0 \
|
|
104
|
+
InstanceType=c5.xlarge \
|
|
105
|
+
CreateKeyPair=true \
|
|
106
|
+
--capabilities CAPABILITY_IAM
|
|
107
|
+
```
|
|
59
108
|
|
|
60
|
-
<Warning>
|
|
61
|
-
|
|
62
|
-
</Warning>
|
|
109
|
+
<Warning>
|
|
110
|
+
**Security**: Replace `AllowedIngressCidr=0.0.0.0/0` with your specific IP ranges to restrict VPC access.
|
|
111
|
+
</Warning>
|
|
63
112
|
|
|
64
|
-
### Get Your Launch Template ID
|
|
113
|
+
### Get Your Launch Template ID
|
|
65
114
|
|
|
66
|
-
After deployment completes, retrieve the launch template ID:
|
|
115
|
+
After deployment completes, retrieve the launch template ID:
|
|
67
116
|
|
|
68
|
-
```bash
|
|
69
|
-
aws cloudformation describe-stacks \
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```
|
|
117
|
+
```bash
|
|
118
|
+
aws cloudformation describe-stacks \
|
|
119
|
+
--stack-name testdriver-infrastructure \
|
|
120
|
+
--query 'Stacks[0].Outputs[?OutputKey==`LaunchTemplateId`].OutputValue' \
|
|
121
|
+
--output text
|
|
122
|
+
```
|
|
74
123
|
|
|
75
|
-
<Tip>
|
|
76
|
-
|
|
77
|
-
</Tip>
|
|
124
|
+
<Tip>
|
|
125
|
+
**Save this ID** — you'll need it for spawning instances and CI configuration.
|
|
126
|
+
</Tip>
|
|
127
|
+
</Tab>
|
|
128
|
+
</Tabs>
|
|
78
129
|
|
|
79
130
|
## Step 2: Spawn Test Instances
|
|
80
131
|
|
|
81
|
-
Use the `spawn-runner.sh` script to launch instances on-demand. This script:
|
|
132
|
+
Use the [`spawn-runner.sh`](https://github.com/testdriverai/testdriverai/blob/main/setup/aws/spawn-runner.sh) script to launch instances on-demand. This script:
|
|
82
133
|
|
|
83
134
|
- Launches a new EC2 instance using your launch template
|
|
84
135
|
- Waits for the instance to be ready
|
|
85
|
-
-
|
|
136
|
+
- Validates SSM connectivity
|
|
86
137
|
- Returns instance details for test execution
|
|
87
138
|
|
|
88
139
|
```bash
|
|
89
|
-
|
|
90
|
-
export AWS_REGION=us-east-2
|
|
91
|
-
export AMI_ID=ami-086b5b4b86d78987c
|
|
92
|
-
export AWS_LAUNCH_TEMPLATE_ID=lt-your-template-id
|
|
93
|
-
export RESOLUTION=1440x900 # Optional, default is 1440x900
|
|
94
|
-
|
|
95
|
-
# Spawn an instance
|
|
96
|
-
./setup/aws/spawn-runner.sh
|
|
140
|
+
AWS_REGION=us-east-2 AMI_ID=ami-0504bf50fad62f312 AWS_LAUNCH_TEMPLATE_ID=lt-your-template-id sh setup/aws/spawn-runner.sh
|
|
97
141
|
```
|
|
98
142
|
|
|
99
143
|
Output:
|
|
@@ -105,10 +149,28 @@ AWS_REGION=us-east-2
|
|
|
105
149
|
|
|
106
150
|
### Run Tests Against Your Instance
|
|
107
151
|
|
|
108
|
-
|
|
152
|
+
Specify the instance IP using the `TD_IP` environment variable:
|
|
109
153
|
|
|
110
154
|
```bash
|
|
111
|
-
TD_API_KEY=your-api-key
|
|
155
|
+
TD_API_KEY=your-api-key TD_IP=1.2.3.4 npx vitest run
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
In your test file, pass the IP to TestDriver:
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
import { describe, it } from "vitest";
|
|
162
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
163
|
+
|
|
164
|
+
describe("My Test", () => {
|
|
165
|
+
it("should run on self-hosted instance", async (context) => {
|
|
166
|
+
const testdriver = TestDriver(context, {
|
|
167
|
+
ip: process.env.TD_IP,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
await testdriver.provision.chrome({ url: "https://example.com" });
|
|
171
|
+
// ... your test steps
|
|
172
|
+
});
|
|
173
|
+
});
|
|
112
174
|
```
|
|
113
175
|
|
|
114
176
|
### Terminate Instances
|
|
@@ -176,7 +238,7 @@ jobs:
|
|
|
176
238
|
run: npx vitest run
|
|
177
239
|
env:
|
|
178
240
|
TD_API_KEY: ${{ secrets.TD_API_KEY }}
|
|
179
|
-
|
|
241
|
+
TD_IP: ${{ steps.aws-setup.outputs.public-ip }}
|
|
180
242
|
|
|
181
243
|
- name: Shutdown AWS Instance
|
|
182
244
|
if: always()
|
|
@@ -198,9 +260,60 @@ jobs:
|
|
|
198
260
|
| `AWS_SECRET_ACCESS_KEY` | AWS secret key | `wJalrXUtnFEMI/K7MDENG...` |
|
|
199
261
|
| `AWS_REGION` | AWS region | `us-east-2` |
|
|
200
262
|
| `AWS_LAUNCH_TEMPLATE_ID` | From CloudFormation output | `lt-07c53ce8349b958d1` |
|
|
201
|
-
| `AMI_ID` | TestDriver AMI ID | `ami-
|
|
263
|
+
| `AMI_ID` | TestDriver AMI ID | `ami-0504bf50fad62f312` |
|
|
202
264
|
| `TD_API_KEY` | Your TestDriver API key | From [console.testdriver.ai](https://console.testdriver.ai) |
|
|
203
265
|
|
|
266
|
+
### Example Workflow
|
|
267
|
+
|
|
268
|
+
For a complete real-world example with matrix-based test execution and dynamic test file discovery, see the [`self-hosted.yml`](https://github.com/testdriverai/testdriverai/blob/main/setup/aws/self-hosted.yml) workflow in the TestDriver repository.
|
|
269
|
+
|
|
270
|
+
<Tip>
|
|
271
|
+
**Local Testing**: You can test your GitHub Actions workflow locally using [nektos/act](https://github.com/nektos/act). The `self-hosted.yml` workflow includes commented lines for installing the AWS CLI when running with `act`.
|
|
272
|
+
</Tip>
|
|
273
|
+
|
|
274
|
+
## Manual Instance Management
|
|
275
|
+
|
|
276
|
+
You can manage TestDriver instances manually through the AWS Console or CLI. This is useful for debugging, development, or running tests outside of CI/CD.
|
|
277
|
+
|
|
278
|
+
### Starting an Instance
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
aws ec2 run-instances \
|
|
282
|
+
--region us-east-2 \
|
|
283
|
+
--image-id ami-0504bf50fad62f312 \
|
|
284
|
+
--launch-template LaunchTemplateId=lt-your-template-id \
|
|
285
|
+
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=testdriver-manual}]'
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Stopping an Instance
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
aws ec2 stop-instances --region us-east-2 --instance-ids i-1234567890abcdef0
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Starting a Stopped Instance
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
aws ec2 start-instances --region us-east-2 --instance-ids i-1234567890abcdef0
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Terminating Instances
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
aws ec2 terminate-instances --region us-east-2 --instance-ids i-1234567890abcdef0
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Connecting to an Instance
|
|
307
|
+
|
|
308
|
+
You can connect to running instances via:
|
|
309
|
+
- **RDP** — Use the public IP on port 3389
|
|
310
|
+
- **VNC** — Access via web browser at `http://<public-ip>:5900`
|
|
311
|
+
- **AWS Console** — Use EC2 Instance Connect or Session Manager
|
|
312
|
+
|
|
313
|
+
<Note>
|
|
314
|
+
Stopped instances retain their EBS volumes and can be restarted later. Terminated instances are permanently deleted. Always terminate instances when done to avoid storage costs.
|
|
315
|
+
</Note>
|
|
316
|
+
|
|
204
317
|
## AMI Customization
|
|
205
318
|
|
|
206
319
|
The TestDriver Golden Image comes pre-configured with:
|
package/package.json
CHANGED
|
@@ -81,8 +81,8 @@ Parameters:
|
|
|
81
81
|
|
|
82
82
|
CreateKeyPair:
|
|
83
83
|
Type: String
|
|
84
|
-
AllowedValues: [yes, no]
|
|
85
|
-
Default: yes
|
|
84
|
+
AllowedValues: ["yes", "no"]
|
|
85
|
+
Default: "yes"
|
|
86
86
|
Description: Create a new key pair for instance access? (If 'no', you must provide an existing key name)
|
|
87
87
|
ExistingKeyName:
|
|
88
88
|
Type: String
|
|
@@ -168,15 +168,15 @@ Resources:
|
|
|
168
168
|
IpProtocol: tcp,
|
|
169
169
|
FromPort: 8765,
|
|
170
170
|
ToPort: 8765,
|
|
171
|
-
CidrIp:
|
|
172
|
-
Description: "pyautogui-cli WebSockets -
|
|
171
|
+
CidrIp: 0.0.0.0/0,
|
|
172
|
+
Description: "pyautogui-cli WebSockets - Open for testing",
|
|
173
173
|
}
|
|
174
174
|
- {
|
|
175
175
|
IpProtocol: tcp,
|
|
176
|
-
FromPort:
|
|
177
|
-
ToPort:
|
|
178
|
-
CidrIp:
|
|
179
|
-
Description: "
|
|
176
|
+
FromPort: 5800,
|
|
177
|
+
ToPort: 5800,
|
|
178
|
+
CidrIp: !Ref AllowedIngressCidr,
|
|
179
|
+
Description: "WebVNC 5800",
|
|
180
180
|
}
|
|
181
181
|
- {
|
|
182
182
|
IpProtocol: tcp,
|
|
@@ -30,9 +30,8 @@ describe("Scroll Keyboard Test", () => {
|
|
|
30
30
|
await testdriver.scroll("down", { amount: 1000 });
|
|
31
31
|
|
|
32
32
|
// Assert the page is scrolled down
|
|
33
|
-
const result = await testdriver.assert(
|
|
34
|
-
|
|
35
|
-
);
|
|
33
|
+
const result = await testdriver.assert("the page is scrolled down, the hamster dance h1 text heading is not visible on the webpage");
|
|
34
|
+
|
|
36
35
|
expect(result).toBeTruthy();
|
|
37
36
|
});
|
|
38
37
|
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example test demonstrating GitHub comment integration
|
|
3
|
-
*
|
|
4
|
-
* When run in CI with proper environment variables set, this will:
|
|
5
|
-
* 1. Run the tests
|
|
6
|
-
* 2. Record dashcam replays
|
|
7
|
-
* 3. Post a beautiful GitHub comment with results
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { describe, expect, it } from "vitest";
|
|
11
|
-
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
12
|
-
|
|
13
|
-
describe("GitHub Comment Demo", () => {
|
|
14
|
-
it("should pass with dashcam replay", async (context) => {
|
|
15
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
16
|
-
|
|
17
|
-
await testdriver.provision.chrome({
|
|
18
|
-
url: 'https://www.example.com',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const heading = await testdriver.find("heading with Example Domain");
|
|
22
|
-
const result = await testdriver.assert("I can see 'Example Domain' heading");
|
|
23
|
-
expect(result).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("should demonstrate failure handling", async (context) => {
|
|
27
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
28
|
-
|
|
29
|
-
await testdriver.provision.chrome({
|
|
30
|
-
url: 'https://www.example.com',
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// This will fail intentionally to show error reporting
|
|
34
|
-
const result = await testdriver.assert("I can see a navigation menu with 20 items");
|
|
35
|
-
expect(result).toBeTruthy(); // This will fail
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("should skip when needed", async (context) => {
|
|
39
|
-
// Skipped tests show in the summary
|
|
40
|
-
context.skip();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TestDriver SDK - Reconnect Test Part 2: Sign In
|
|
3
|
-
*
|
|
4
|
-
* This test reconnects to the sandbox provisioned by reconnect-provision.test.mjs
|
|
5
|
-
* and clicks the Sign In button.
|
|
6
|
-
*
|
|
7
|
-
* IMPORTANT: Run this within 2 minutes of reconnect-provision.test.mjs completing.
|
|
8
|
-
* The sandbox auto-terminates after the keepAlive TTL (default 2 minutes).
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
* 1. npm test -- test/testdriver/reconnect-provision.test.mjs
|
|
12
|
-
* 2. (within 2 minutes) npm test -- test/testdriver/reconnect-signin.test.mjs
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { describe, expect, it } from "vitest";
|
|
16
|
-
import { TestDriver } from "../../lib/vitest/hooks.mjs";
|
|
17
|
-
|
|
18
|
-
describe("Reconnect Test - Part 2: Sign In", () => {
|
|
19
|
-
|
|
20
|
-
it("should reconnect to existing sandbox and click Sign In", async (context) => {
|
|
21
|
-
|
|
22
|
-
const testdriver = TestDriver(context, { newSandbox: true, headless: false, reconnect: true });
|
|
23
|
-
|
|
24
|
-
// Provision Chrome and navigate to login page
|
|
25
|
-
await testdriver.provision.chrome({
|
|
26
|
-
url: 'http://testdriver-sandbox.vercel.app/login',
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Click on Sign In button - the page should already be loaded from provision test
|
|
30
|
-
const signInButton = await testdriver.find(
|
|
31
|
-
"Sign In, black button below the password field",
|
|
32
|
-
);
|
|
33
|
-
await signInButton.click();
|
|
34
|
-
|
|
35
|
-
// Assert that an error shows that fields are required
|
|
36
|
-
const result = await testdriver.assert(
|
|
37
|
-
"an error shows that fields are required",
|
|
38
|
-
);
|
|
39
|
-
expect(result).toBeTruthy();
|
|
40
|
-
});
|
|
41
|
-
});
|