testdriverai 5.5.4 → 5.5.6

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 (128) hide show
  1. package/agent.js +29 -39
  2. package/docs/account/dashboard.mdx +16 -0
  3. package/docs/account/enterprise.mdx +97 -0
  4. package/docs/account/pricing.mdx +26 -0
  5. package/docs/account/projects.mdx +27 -0
  6. package/docs/account/team.mdx +31 -0
  7. package/docs/action/browser.mdx +1 -1
  8. package/docs/action/os.mdx +1 -2
  9. package/docs/action/output.mdx +2 -2
  10. package/docs/action/performance.mdx +4 -0
  11. package/docs/action/prerun.mdx +57 -1
  12. package/docs/action/secrets.mdx +3 -3
  13. package/docs/action/setup.mdx +6 -6
  14. package/docs/apps/chrome-extensions.mdx +41 -0
  15. package/docs/apps/desktop-apps.mdx +87 -0
  16. package/docs/apps/mobile-apps.mdx +22 -0
  17. package/docs/apps/static-websites.mdx +54 -0
  18. package/docs/bugs/jira.mdx +35 -28
  19. package/docs/cli/overview.mdx +19 -13
  20. package/docs/commands/assert.mdx +2 -0
  21. package/docs/commands/exec.mdx +96 -0
  22. package/docs/commands/focus-application.mdx +2 -0
  23. package/docs/commands/hover-image.mdx +2 -0
  24. package/docs/commands/hover-text.mdx +2 -0
  25. package/docs/commands/if.mdx +3 -2
  26. package/docs/commands/issues.mdx +27 -0
  27. package/docs/commands/match-image.mdx +2 -0
  28. package/docs/commands/press-keys.mdx +9 -5
  29. package/docs/commands/run.mdx +2 -1
  30. package/docs/commands/scroll-until-image.mdx +3 -1
  31. package/docs/commands/scroll-until-text.mdx +2 -0
  32. package/docs/commands/scroll.mdx +3 -1
  33. package/docs/commands/type.mdx +3 -1
  34. package/docs/commands/wait-for-image.mdx +3 -1
  35. package/docs/commands/wait-for-text.mdx +3 -1
  36. package/docs/commands/wait.mdx +3 -1
  37. package/docs/docs.json +260 -146
  38. package/docs/exporting/playwright.mdx +33 -26
  39. package/docs/features/auto-healing.mdx +25 -20
  40. package/docs/features/cross-platform.mdx +9 -8
  41. package/docs/features/generation.mdx +4 -3
  42. package/docs/features/github.mdx +22 -18
  43. package/docs/features/parallel-testing.mdx +15 -11
  44. package/docs/features/reusable-snippets.mdx +18 -14
  45. package/docs/features/selectorless.mdx +8 -3
  46. package/docs/features/visual-assertions.mdx +9 -10
  47. package/docs/getting-started/ci.mdx +7 -8
  48. package/docs/getting-started/editing.mdx +2 -0
  49. package/docs/getting-started/generating.mdx +1 -1
  50. package/docs/getting-started/running.mdx +2 -2
  51. package/docs/getting-started/setup.mdx +5 -12
  52. package/docs/getting-started/vscode.mdx +67 -79
  53. package/docs/getting-started/writing.mdx +7 -5
  54. package/docs/guide/assertions.mdx +6 -6
  55. package/docs/guide/authentication.mdx +18 -14
  56. package/docs/guide/code.mdx +3 -3
  57. package/docs/guide/environment-variables.mdx +64 -0
  58. package/docs/guide/lifecycle.mdx +154 -0
  59. package/docs/guide/locating.mdx +9 -9
  60. package/docs/guide/variables.mdx +9 -6
  61. package/docs/guide/waiting.mdx +9 -8
  62. package/docs/images/content/account/newprojectsettings.png +0 -0
  63. package/docs/images/content/account/projectpage.png +0 -0
  64. package/docs/images/content/account/projectreplays.png +0 -0
  65. package/docs/images/content/account/team-manage.png +0 -0
  66. package/docs/images/content/account/teampage.png +0 -0
  67. package/docs/images/content/side-by-side.png +0 -0
  68. package/docs/images/content/vscode/vscode-agent-preview.png +0 -0
  69. package/docs/images/content/vscode/vscode-copilot-ask.png +0 -0
  70. package/docs/images/content/vscode/vscode-file-creation.png +0 -0
  71. package/docs/images/content/vscode/vscode-install.png +0 -0
  72. package/docs/images/content/vscode/vscode-overview.png +0 -0
  73. package/docs/images/content/vscode/vscode-setup-walkthrough.png +0 -0
  74. package/docs/images/content/vscode/vscode-stopchat.png +0 -0
  75. package/docs/images/content/vscode/vscode-stoptest.png +0 -0
  76. package/docs/images/content/vscode/vscode-tdservice.png +0 -0
  77. package/docs/images/content/vscode/vscode-test-output.png +0 -0
  78. package/docs/images/content/vscode/vscode-testhistory.png +0 -0
  79. package/docs/images/content/vscode/vscode-testpane-runtests.png +0 -0
  80. package/docs/images/content/vscode/vscode-testpane.png +0 -0
  81. package/docs/importing/csv.mdx +9 -6
  82. package/docs/importing/gherkin.mdx +12 -10
  83. package/docs/importing/jira.mdx +11 -9
  84. package/docs/importing/testrail.mdx +10 -8
  85. package/docs/integrations/electron.mdx +26 -19
  86. package/docs/integrations/netlify.mdx +25 -24
  87. package/docs/integrations/vercel.mdx +22 -20
  88. package/docs/interactive/assert.mdx +4 -1
  89. package/docs/interactive/dry.mdx +51 -0
  90. package/docs/interactive/explore.mdx +92 -0
  91. package/docs/interactive/generate.mdx +6 -3
  92. package/docs/interactive/run.mdx +3 -0
  93. package/docs/interactive/save.mdx +3 -0
  94. package/docs/interactive/undo.mdx +3 -0
  95. package/docs/overview/comparison.mdx +6 -2
  96. package/docs/overview/faq.mdx +2 -1
  97. package/docs/overview/quickstart.mdx +123 -65
  98. package/docs/overview/upgrading.mdx +82 -0
  99. package/docs/overview/what-is-testdriver.mdx +13 -5
  100. package/docs/quickstart.mdx +1 -1
  101. package/docs/scenarios/ai-chatbot.mdx +26 -0
  102. package/docs/scenarios/cookie-banner.mdx +30 -0
  103. package/docs/scenarios/file-upload.mdx +30 -0
  104. package/docs/scenarios/form-filling.mdx +28 -0
  105. package/docs/scenarios/log-in.mdx +68 -0
  106. package/docs/scenarios/pdf-generation.mdx +21 -0
  107. package/docs/scenarios/spell-check.mdx +21 -0
  108. package/docs/security/action.mdx +7 -3
  109. package/docs/security/agent.mdx +1 -1
  110. package/docs/security/platform.mdx +9 -1
  111. package/docs/snippets/calendar-link.mdx +1 -0
  112. package/docs/snippets/gitignore-warning.mdx +4 -0
  113. package/docs/snippets/test-prereqs.mdx +15 -0
  114. package/docs/tutorials/advanced-test.mdx +2 -0
  115. package/docs/tutorials/basic-test.mdx +8 -7
  116. package/lib/commands.js +40 -21
  117. package/lib/config.js +0 -1
  118. package/lib/logger.js +2 -2
  119. package/lib/parser.js +1 -0
  120. package/lib/sdk.js +32 -26
  121. package/package.json +2 -1
  122. package/schema.json +1 -4
  123. package/styles/config/vocabularies/Docs/accept.txt +15 -2
  124. package/styles/config/vocabularies/Docs/reject.txt +4 -0
  125. package/docs/30x30.mdx +0 -84
  126. package/docs/issues.mdx +0 -9
  127. package/docs/security/dashboard.mdx +0 -0
  128. package/testdriver/chrome.yaml +0 -102
@@ -1,21 +1,29 @@
1
1
  ---
2
2
  title: "What is TestDriver?"
3
+ sidebarTitle: "What is TestDriver?"
3
4
  description: "TestDriver is a computer-use agent for QA testing of user interfaces."
4
5
  icon: "circle-info"
5
- mode: "wide"
6
6
  ---
7
7
 
8
8
  TestDriver uses AI vision and keyboard and mouse control to automate end-to-end testing. TestDriver is `selectorless` meaning it isn't aware of the underlying code structure.
9
9
 
10
- - **Easier set up:** No need to craft complex selectors
11
- - **Less Maintenance:** Tests don't break when code changes
12
- - **More Power:** TestDriver can test any application and control any OS setting
10
+ <CardGroup cols={3}>
11
+ <Card title="Easier Setup" icon="wrench">
12
+ No need to craft complex selectors.
13
+ </Card>
14
+ <Card title="More Power" icon="bolt">
15
+ TestDriver can test anything a user can do.
16
+ </Card>
17
+ <Card title="Less Maintenance" icon="bandage">
18
+ Tests don't break when code changes.
19
+ </Card>
20
+ </CardGroup>
13
21
 
14
22
  TestDriver is different from other computer-use agents in that it produces a `YAML` test script that increases the speed and repeatability of testing.
15
23
 
16
24
  ### Selectorless Testing
17
25
 
18
- Unlike traditional frameworks (e.g., Selenium, Playwright), TestDriver doesnt rely on CSS selectors or static analysis. Instead, tests are described in plain English, such as:
26
+ Unlike traditional frameworks (e.g., Selenium, Playwright), TestDriver doesn't rely on CSS selectors or static analysis. Instead, tests are described in plain English, such as:
19
27
 
20
28
  ```
21
29
  > Open Google Chrome and search for "testdriver"
@@ -26,7 +26,7 @@ Start TestDriver in interactive mode to create and refine tests dynamically:
26
26
  ```bash
27
27
  testdriverai
28
28
  ```
29
- Once started, you can use commands like `/try`, `/undo`, and `/save` to interactively build and test your flows.
29
+ Once started, you can use commands like `/explore`, `/undo`, and `/save` to interactively build and test your flows.
30
30
  </Step>
31
31
 
32
32
  <Step title="Define Your Test Steps">
@@ -0,0 +1,26 @@
1
+ ---
2
+ title: "AI Chatbot"
3
+ sidebarTitle: "AI Chatbot"
4
+ description: "Integrate AI chatbots into your testing workflow."
5
+ icon: "message-bot"
6
+ ---
7
+
8
+ import TestPrereqs from '/snippets/test-prereqs.mdx'
9
+
10
+ TestDriver can be used to test AI chatbots, or any two way assertions like:
11
+ - Approval workflows
12
+ - Chatbots
13
+ - Email or SMS notifications
14
+ - And more!
15
+
16
+
17
+ This scenario is an example of how to set up and run tests for an AI chatbot using TestDriver.
18
+
19
+ <TestPrereqs />
20
+
21
+ ## Scenario Overview
22
+ 1. Load a website with an AI chatbot.
23
+ 2. Type a chat message or ask a question.
24
+ 3. Wait for the chatbot to respond.
25
+ 4. Verify that the chatbot's response is correct and meets the expected criteria.
26
+
@@ -0,0 +1,30 @@
1
+ ---
2
+ title: "Cookie Banner"
3
+ sidebarTitle: "Cookie Banner"
4
+ description: "Test cookie banners with TestDriver"
5
+ icon: "cookie"
6
+ ---
7
+
8
+ import TestPrereqs from '/snippets/test-prereqs.mdx'
9
+
10
+ With TestDriver, you can automate the testing of cookie banners on your web application. This scenario demonstrates how to check if a cookie banner appears when a user visits the site and how to interact with it.
11
+
12
+ <TestPrereqs />
13
+
14
+ ## Scenario Overview
15
+ 1. **Visit the Site**: The test will navigate to the target URL.
16
+ 2. **Check for Cookie Banner**: It will verify if the cookie banner is displayed.
17
+ 3. **Decline Cookies**: The test will simulate a user clicking the "Decline All" button on the cookie banner.
18
+
19
+
20
+
21
+ ## TestDriver in Action
22
+ <iframe
23
+ width="560"
24
+ height="315"
25
+ src="https://www.youtube.com/embed/mhTffX0SG94"
26
+ title="Testing Cookie Banners with TestDriver"
27
+ frameborder="0"
28
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
29
+ allowfullscreen
30
+ ></iframe>
@@ -0,0 +1,30 @@
1
+ ---
2
+ title: "File Upload"
3
+ sidebarTitle: "File Upload"
4
+ description: "Test file upload functionality with TestDriver"
5
+ icon: "upload"
6
+ ---
7
+
8
+ import TestPrereqs from '/snippets/test-prereqs.mdx'
9
+
10
+ This scenario demonstrates how to automate testing the file upload functionality of a web application using TestDriver's capabilities. The test will check if the file upload process works correctly and if the uploaded file is processed as expected.
11
+
12
+ <TestPrereqs />
13
+
14
+ ## Scenario Overview
15
+ 1. Load a website with a file upload feature.
16
+ 2. Generate a file that will be used for the upload.
17
+ 3. Use TestDriver to perform the file upload process.
18
+ 4. Check if the uploaded file is processed correctly by the application.
19
+
20
+
21
+ ## TestDriver in Action
22
+ <iframe
23
+ width="560"
24
+ height="315"
25
+ src="https://www.youtube.com/embed/50AN5hDnwAg"
26
+ title="File Upload Testing with TestDriver"
27
+ frameborder="0"
28
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
29
+ allowfullscreen
30
+ ></iframe>
@@ -0,0 +1,28 @@
1
+ ---
2
+ title: "Form Filling"
3
+ sidebarTitle: "Form Filling"
4
+ description: "Test form filling functionality with TestDriver"
5
+ icon: "list"
6
+ ---
7
+
8
+ import TestPrereqs from '/snippets/test-prereqs.mdx'
9
+
10
+ <TestPrereqs />
11
+
12
+ ## Scenario Overview
13
+ 1. Open a webpage containing a form (Log in, Registration, etc.).
14
+ 2. Use TestDriver to fill in the form fields with test data.
15
+ 3. Submit the form and verify the expected outcome (e.g., successful login, registration confirmation, redirect etc.).
16
+
17
+
18
+
19
+ ## TestDriver in Action
20
+ <iframe
21
+ width="560"
22
+ height="315"
23
+ src="https://www.youtube.com/embed/CqdRN_5_3I0"
24
+ title="Form Filling With TestDriver"
25
+ frameborder="0"
26
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
27
+ allowfullscreen
28
+ ></iframe>
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: "Login Scenario"
3
+ sidebarTitle: "Login"
4
+ description: "Test login functionality with TestDriver"
5
+ icon: "lock"
6
+ ---
7
+
8
+ import TestPrereqs from '/snippets/test-prereqs.mdx'
9
+
10
+ Test login functionality with TestDriver. This scenario demonstrates how to automate testing the login process for a web application using TestDriver.
11
+
12
+ <TestPrereqs />
13
+
14
+ ## Scenario Overview
15
+ 1. Visit the login page of the web application.
16
+ 2. Enter the username and password into the respective fields (see [Reusable Snippets](/features/reusable-snippets#How-to Create-and-Use-Reusable-Snippets)).
17
+ 3. Click the "Login" button.
18
+ 4. Verify that the user is redirected to the dashboard or home page after a successful login.
19
+ 5. Optionally, check if the user is logged in by verifying the presence of a logout button or user profile information.
20
+
21
+
22
+ ### Setup your test environment with predefined credentials.
23
+ In this example, we will use GitHub secret management to store our credentials.
24
+
25
+ <Tip>You can also use the [`exec`](commands/exec) command to fetch a test user dynamically from a database or API.</Tip>
26
+
27
+ To use GitHub secrets, create or modify an existing `.env` file in the root of your project and add the following lines:
28
+
29
+ ```bash
30
+ TD_TEST_USERNAME=your_test_username
31
+ TD_TEST_PASSWORD=your_test_password
32
+ ```
33
+
34
+ 2. Create a test file and use the credentials like this:
35
+
36
+ ```yaml
37
+ version: 4.2.18
38
+ steps:
39
+ - prompt: Log in to the application
40
+ commands:
41
+ - command: hover-text
42
+ text: Email address
43
+ description: email input field label
44
+ action: click
45
+ - command: type
46
+ text: ${TD_USERNAME} # Use environment variable for username
47
+ - command: hover-text
48
+ text: Password
49
+ description: password input field label
50
+ action: click
51
+ - command: type
52
+ text: ${TD_PASSWORD} # Use environment variable for password
53
+ - command: hover-text
54
+ text: Log In
55
+ description: log in button
56
+ action: click
57
+ ```
58
+
59
+ 3. Run the test using the command line:
60
+
61
+ ```bash
62
+ testdriverai run login.yaml
63
+ ```
64
+
65
+ 4. Watch replays in [Your account](https://app.testdriver.ai)
66
+
67
+ ### Conclusion
68
+ In this scenario, we demonstrated how to automate the login process for a web application using TestDriver. By leveraging reusable snippets and environment variables, you can create efficient and maintainable tests for your applications. This approach not only saves time but also ensures that your tests are easily adaptable to changes in the application or test data.
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: "PDF Generation"
3
+ sidebarTitle: "PDF Generation"
4
+ description: "Test PDF generation functionality with TestDriver"
5
+ icon: "file-pdf"
6
+ ---
7
+
8
+ import TestPrereqs from '/snippets/test-prereqs.mdx'
9
+
10
+ Test PDF generation functionality with TestDriver. This scenario demonstrates how to automate testing the PDF generation process for a web application using TestDriver's capabilities.
11
+
12
+ <TestPrereqs />
13
+
14
+ ## Scenario Overview
15
+ 1. Open a webpage or desktop app that will allow you to generate a PDF.
16
+ 2. Trigger the PDF generation process (e.g., by clicking a button).
17
+ 3. Verify that the PDF is generated successfully and contains the expected content.
18
+ 4. Optionally, check the file size and format of the generated PDF.
19
+
20
+ ## What Next?
21
+ From here you can automate and add coverage to your PDF generation process, removing manual testing from the equation.
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: "Spell Check"
3
+ sidebarTitle: "Spell Check"
4
+ description: "Test spell check functionality with TestDriver"
5
+ icon: "spell-check"
6
+ ---
7
+
8
+ import TestPrereqs from '/snippets/test-prereqs.mdx'
9
+
10
+ This scenario demonstrates how to automate testing the spell check functionality of a web application using TestDriver's capabilities. The test will check if the spell checker correctly identifies and suggests corrections for misspelled words in a text input field.
11
+
12
+ <TestPrereqs />
13
+
14
+ ## Scenario Overview
15
+ 1. Open up a webpage that has text input and a spell check function.
16
+ 2. Enter a misspelled word into the text input field.
17
+ 3. Trigger the spell check function (e.g., by clicking a button or losing focus on the input field).
18
+ 4. Verify that the spell checker identifies the misspelled word and provides suggestions for correction.
19
+ 5. Optionally, select a suggestion and apply it to the text input field.
20
+
21
+
@@ -2,13 +2,15 @@
2
2
  title: "Security Features of the TestDriver Action"
3
3
  sidebarTitle: "GitHub Action"
4
4
  description: "Understand the ephemeral VM runners, secrets handling, and environment-specific security for the TestDriver Action."
5
- icon: "code-pull-request"
5
+ icon: shield-check
6
6
  ---
7
7
 
8
+ import GitignoreWarning from '/snippets/gitignore-warning.mdx';
9
+
8
10
  ## Open Source
9
11
  The TestDriver Action is open source, and its source code is available for review. You can find the repository here:
10
12
 
11
- [GitHub - testdriverai/action](https://github.com/testdriverai/action)
13
+ <Card horizontal="true" icon="github"> [GitHub - testdriverai/action](https://github.com/testdriverai/action) </Card>
12
14
 
13
15
  ## Ephemeral Virtual Machine Runners
14
16
  TestDriver tests are executed on private virtual machines (VMs) managed by Amazon EC2. These VMs are ephemeral, meaning they only exist for the duration of the test execution. Once the test is complete:
@@ -20,7 +22,7 @@ To securely manage private information, we recommend storing sensitive data as s
20
22
 
21
23
  ### Handling Secrets
22
24
  - **Prerun Scripts**: Any secrets supplied within prerun scripts or prompts are transmitted over SSL to the TestDriver API. Prerun scripts are **not persisted**.
23
- - **Agent Prompts**: Secrets supplied to agent prompts are persisted (see [Agent Security](../agent)).
25
+ - **Agent Prompts**: Secrets supplied to agent prompts are persisted (see [Agent Security](/security/agent)).
24
26
  - **Secure Workflows**: If your workflow requires secret sharing and you encounter issues, please contact us for assistance.
25
27
 
26
28
  ### Common Use Case
@@ -28,6 +30,8 @@ A common workflow involves using prerun scripts to securely access a private sta
28
30
 
29
31
  ## Environment-Specific Security
30
32
 
33
+ <GitignoreeWarning/>
34
+
31
35
  ### Production
32
36
  Testing production environments is the simplest and most secure starting point.
33
37
  - Production testing doesn't require any private information from your team.
@@ -2,7 +2,7 @@
2
2
  title: "Security Features of the TestDriver Agent"
3
3
  sidebarTitle: "TestDriver Agent "
4
4
  description: "Explore the data collected, persistence, and privacy practices of the TestDriver Agent."
5
- icon: "robot"
5
+ icon: lock-keyhole
6
6
  ---
7
7
 
8
8
  ## Source
@@ -2,9 +2,11 @@
2
2
  title: "Security Features of the Dashboard"
3
3
  sidebarTitle: "TestDriver Platform"
4
4
  description: "Learn about the security features of the TestDriver web dashboard, including SSL, OAuth, RBAC, and more."
5
- icon: "layer-group"
5
+ icon: layer-group
6
6
  ---
7
7
 
8
+ import GitignoreWarning from '/snippets/gitignore-warning.mdx';
9
+
8
10
  ## Overview
9
11
  The TestDriver web dashboard provides a secure interface for managing and reviewing your tests. Tests executed via the GitHub Action are recorded and reported through Dashcam, another application developed by TestDriver. For more details, refer to the [Dashcam documentation](https://dashcam.docs.testdriver.ai).
10
12
 
@@ -34,6 +36,12 @@ Dashcam and TestDriver share the same API and web application back end, which in
34
36
  - Teams can rotate their API key for enhanced security.
35
37
  - It is recommended to rotate the API key every 90 days to minimize risk.
36
38
 
39
+ <Check>
40
+ For more details on **Team Management** see the [Team documentation](/account/team).
41
+ </Check>
42
+
43
+ <GitignoreWarning/>
44
+
37
45
  ### Secret Masking
38
46
  - Test replay logs and network requests are automatically scanned for sensitive information, such as:
39
47
  - Credit card numbers
@@ -0,0 +1 @@
1
+ export const calendar = 'https://calendly.com/d/cq23-qyn-3v6/testdriver-ai-demo';
@@ -0,0 +1,4 @@
1
+ <Warning>
2
+ Always remember to add a `.gitignore` file to your repository including a `.env` line so you never accidentally commit you TestDriver API key.
3
+ This is important for security and to prevent exposing sensitive information. For more info see [GitHub Docs](https://docs.github.com/en/get-started/git-basics/ignoring-files).
4
+ </Warning>
@@ -0,0 +1,15 @@
1
+ ## Prerequisites
2
+ Before running the tests, ensure you have performed the following steps:
3
+
4
+ 1. Install the [VS Code Extension](/getting-started/vscode) for TestDriver
5
+ 2. If you haven't already, signup for a Free Trial on the [TestDriver website](https://testdriver.ai/pricing)
6
+ 3. Install the [TestDriver CLI](/cli/overview) globally using npm or just follow the VS Code Extension Setup Walkthrough:
7
+ ```bash
8
+ npm install -g @testdriverai@beta
9
+ ```
10
+ 4. Run the `init` command to set up the TestDriver configuration using the API key you got when you signed up for the trial:
11
+ ```bash
12
+ testdriverai init
13
+ ```
14
+
15
+ <Check>Now you are ready to run the tests!</Check>
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  title: "Tutorial: Advanced Test"
3
3
  description: "Explore advanced testing techniques and features in TestDriver."
4
+ sidebarTitle: "Advanced Test"
5
+ icon: "flask-round"
4
6
  ---
5
7
 
6
8
  # Advanced Test Tutorial
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  title: "Tutorial: Basic Test"
3
3
  description: "Learn how to create and run a basic test using TestDriver."
4
+ sidebarTitle: "Basic Test"
5
+ icon: "test-tube"
4
6
  ---
5
7
 
6
8
  # Basic Test Tutorial
@@ -18,20 +20,19 @@ Before you begin, ensure you have the following:
18
20
  To create a test, follow these steps:
19
21
  1. Open your code editor.
20
22
  2. Write the test script using TestDriver's syntax.
21
- 3. Save the test script with a `.td` extension.
23
+ 3. Save the test script with a `.yaml` extension.
22
24
 
23
25
  Example:
24
- ```plaintext
25
- test("Example Test", () => {
26
- expect(1 + 1).toBe(2);
27
- });
26
+ ```yaml
27
+
28
+
28
29
  ```
29
30
 
30
31
  ## Step 2: Run the Test
31
32
 
32
33
  To run the test, use the following command:
33
- ```plaintext
34
- testdriver run example-test.td
34
+ ```bash
35
+ testdriverai run example-test.yaml
35
36
  ```
36
37
 
37
38
  This will execute the test and display the results in the console.
package/lib/commands.js CHANGED
@@ -336,7 +336,7 @@ let commands = {
336
336
  logger.info(chalk.dim("thinking..."), true);
337
337
  logger.info("");
338
338
 
339
- const mdStream = createMarkdownStreamLogger();
339
+ // const mdStream = createMarkdownStreamLogger();
340
340
  let response = await sdk.req(
341
341
  "hover/text",
342
342
  {
@@ -349,13 +349,15 @@ let commands = {
349
349
  },
350
350
  (chunk) => {
351
351
  if (chunk.type === "data" && chunk.data) {
352
- mdStream.log(chunk.data);
352
+
353
+ // mdStream.log(chunk.data);
354
+
353
355
  } else if (chunk.type === "closeMatches") {
354
356
  emitter.emit(events.matches.show, chunk.data);
355
357
  }
356
358
  },
357
359
  );
358
- mdStream.end();
360
+ // mdStream.end();
359
361
 
360
362
  if (!response.data) {
361
363
  throw new AiError("No text on screen matches description");
@@ -370,7 +372,7 @@ let commands = {
370
372
  logger.info(chalk.dim("thinking..."), true);
371
373
  logger.info("");
372
374
 
373
- const mdStream = createMarkdownStreamLogger();
375
+ // const mdStream = createMarkdownStreamLogger();
374
376
  let response = await sdk.req(
375
377
  "hover/image",
376
378
  {
@@ -381,13 +383,13 @@ let commands = {
381
383
  },
382
384
  (chunk) => {
383
385
  if (chunk.type === "data") {
384
- mdStream.log(chunk.data);
386
+ // mdStream.log(chunk.data);
385
387
  } else if (chunk.type === "closeMatches") {
386
388
  emitter.emit(events.matches.show, chunk.data);
387
389
  }
388
390
  },
389
391
  );
390
- mdStream.end();
392
+ // mdStream.end();
391
393
 
392
394
  if (!response?.data) {
393
395
  throw new AiError("No image or icon on screen matches description");
@@ -739,7 +741,7 @@ let commands = {
739
741
 
740
742
  let plat = platform();
741
743
 
742
- const scriptCode =
744
+ let scriptCode =
743
745
  plat == "linux"
744
746
  ? linux_code
745
747
  : plat == "windows"
@@ -793,7 +795,7 @@ let commands = {
793
795
  result = await exec(mac_code, { cwd: cwd() });
794
796
  }
795
797
 
796
- if (result.out.exitCode !== 0) {
798
+ if (result.out && result.out.exitCode !== 0) {
797
799
  throw new AiError(
798
800
  `Command failed with exit code ${result.out.exitCode}: ${result.out.stderr}`,
799
801
  true,
@@ -802,10 +804,10 @@ let commands = {
802
804
 
803
805
  if (!silent) {
804
806
  logger.info(chalk.dim(`Command output:`), true);
805
- logger.info(`${result.out.stdout}`, true)
807
+ logger.info(`${result.stdout}`, true)
806
808
  }
807
809
 
808
- return result.out.stdout.trim();
810
+ return result.stdout.trim();
809
811
  }
810
812
 
811
813
  } else if (language == "js") {
@@ -816,29 +818,46 @@ let commands = {
816
818
  true,
817
819
  );
818
820
 
819
- const context = vm.createContext({ require, console, fs, process });
821
+ console.log('')
822
+ console.log('------');
823
+
824
+ const context = vm.createContext({ require, console, fs, process, fetch });
820
825
 
821
- const script = new vm.Script(`
822
- (async () => {
823
- ${scriptCode}
824
- })();
825
- `);
826
+ scriptCode = '(async function() {\n' + scriptCode + '\n})();';
827
+
828
+ const script = new vm.Script(scriptCode);
826
829
 
827
830
  try {
828
- await script.runInContext(context);
831
+ await script.runInNewContext(context);
829
832
  } catch (e) {
833
+ console.error(e);
830
834
  throw new AiError(
831
835
  `Error running script: ${e.message}`,
832
836
  true,
833
837
  );
834
838
  }
835
839
 
836
- if (!context.result) {
837
- logger.info(`No result returned from script`, true);
840
+ // wait for context.result to resolve
841
+ let stepResult = await context.result;
842
+
843
+ // conver it to string
844
+ if (typeof stepResult === "object") {
845
+ stepResult = JSON.stringify(stepResult, null, 2);
846
+ } else if (typeof stepResult === "function") {
847
+ stepResult = stepResult.toString();
838
848
  }
839
849
 
840
- // wait for context.result to resolve
841
- const stepResult = await context.result;
850
+ console.log('------');
851
+ console.log('')
852
+
853
+ if (!stepResult) {
854
+ logger.info(`No result returned from script`, true);
855
+ } else {
856
+ if (!silent) {
857
+ logger.info(chalk.dim(`Result:`), true);
858
+ logger.info(stepResult, true);
859
+ }
860
+ }
842
861
 
843
862
  return stepResult;
844
863
  // }
package/lib/config.js CHANGED
@@ -20,7 +20,6 @@ function parseValue(value) {
20
20
  return value;
21
21
  }
22
22
 
23
- // Object for TD related config, with defaults
24
23
  const config = {
25
24
  TD_SPEAK: false,
26
25
  TD_ANALYTICS: true,
package/lib/logger.js CHANGED
@@ -5,7 +5,7 @@ const server = require("./ipc");
5
5
 
6
6
  // simple match for aws instance i-*
7
7
  const shouldLog =
8
- os.hostname().indexOf("i-") == 0 || process.env["VERBOSE"] == "true";
8
+ os.hostname().indexOf("i-") == 0 || process.env["TD_DEV"] == "true";
9
9
 
10
10
  // responsible for rendering ai markdown output
11
11
  const { marked } = require("marked");
@@ -28,7 +28,7 @@ for (const [key, value] of Object.entries(process.env)) {
28
28
 
29
29
  const censorSensitiveData = (message) => {
30
30
  for (let value of Object.values(interpolationVars)) {
31
- // Avoid replacing vars that are 0 or 1 character
31
+ // Avoid replacing vars that are 0 or 1 characters
32
32
  if (value.length >= 2) {
33
33
  message = message.replaceAll(value, "****");
34
34
  }
package/lib/parser.js CHANGED
@@ -122,6 +122,7 @@ function interpolate (yaml, vars) {
122
122
  });
123
123
  // Replace \$ with $
124
124
  newyaml = newyaml.replace(/\\(\${[^}]+})/g, "$1");
125
+
125
126
  return newyaml;
126
127
  }
127
128