|
| 1 | +--- |
| 2 | +id: smartui-sdk-build-name |
| 3 | +title: Grouping Screenshots through Build Names |
| 4 | +sidebar_label: Fetch Results |
| 5 | +description: In this documentation, learn how to group screenshots in a single build across multiple executions. |
| 6 | + - Visual Regression |
| 7 | + - Visual Regression Testing Guide |
| 8 | + - Visual Regression Test Automation |
| 9 | + - Visual Regression Automation Testing |
| 10 | + - Running Visual Regression Tests |
| 11 | + - Visual Regression Testing Online |
| 12 | + - Run Visual Regression |
| 13 | + - Visual Regression Run Specific Test |
| 14 | + - Visual Regression Testing Environment |
| 15 | + - How to Run Visual Regression Tests |
| 16 | + |
| 17 | +url: https://www.lambdatest.com/support/docs/smartui-cli/ |
| 18 | +slug: smartui-cli-build-name/ |
| 19 | +--- |
| 20 | + |
| 21 | +import Tabs from '@theme/Tabs'; |
| 22 | +import TabItem from '@theme/TabItem'; |
| 23 | +import NewTag from '../src/component/newTag'; |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +<script type="application/ld+json" |
| 28 | + dangerouslySetInnerHTML={{ __html: JSON.stringify({ |
| 29 | + "@context": "https://schema.org", |
| 30 | + "@type": "BreadcrumbList", |
| 31 | + "itemListElement": [{ |
| 32 | + "@type": "ListItem", |
| 33 | + "position": 1, |
| 34 | + "name": "LambdaTest", |
| 35 | + "item": "https://www.lambdatest.com" |
| 36 | + },{ |
| 37 | + "@type": "ListItem", |
| 38 | + "position": 2, |
| 39 | + "name": "Support", |
| 40 | + "item": "https://www.lambdatest.com/support/docs/" |
| 41 | + },{ |
| 42 | + "@type": "ListItem", |
| 43 | + "position": 3, |
| 44 | + "name": "Smart Visual Testing", |
| 45 | + "item": "https://www.lambdatest.com/support/docs/smart-ui-cypress/" |
| 46 | + }] |
| 47 | + }) |
| 48 | + }} |
| 49 | +></script> |
| 50 | + |
| 51 | +SmartUI CLI allows you to group screenshots in a build name and append new screenshots to an existing build. This feature enables you to assign build names, add screenshots to existing builds and manage your visual tests efficiently. |
| 52 | + |
| 53 | + |
| 54 | +## Prerequisites |
| 55 | + |
| 56 | +- Basic understanding of Command Line Interface |
| 57 | +- Login to [LambdaTest SmartUI](https://smartui.lambdatest.com/) with your credentials. |
| 58 | +- Ensure you are using `@lambdatest/smartui-cli` version 4.0.14 or higher. |
| 59 | +- A properly configured SmartUI CLI project |
| 60 | + |
| 61 | +## Steps to Use |
| 62 | + |
| 63 | +### **Step 1:** Install SmartUI CLI |
| 64 | + |
| 65 | +If you haven't already installed SmartUI CLI, install it using npm: |
| 66 | + |
| 67 | +```bash |
| 68 | +npm i @lambdatest/smartui-cli |
| 69 | +``` |
| 70 | + |
| 71 | +### **Step 2:** Configure your Project Token |
| 72 | + |
| 73 | +Setup your project token show in the **SmartUI** app after, creating your project. |
| 74 | + |
| 75 | +<Tabs className="docs__val" groupId="language"> |
| 76 | +<TabItem value="MacOS/Linux" label="MacOS/Linux" default> |
| 77 | + |
| 78 | +```bash |
| 79 | +export PROJECT_TOKEN="123456#1234abcd-****-****-****-************" |
| 80 | +``` |
| 81 | + |
| 82 | +</TabItem> |
| 83 | +<TabItem value="Windows" label="Windows - CMD"> |
| 84 | + |
| 85 | +```bash |
| 86 | +set PROJECT_TOKEN="123456#1234abcd-****-****-****-************" |
| 87 | +``` |
| 88 | + |
| 89 | +</TabItem> |
| 90 | +<TabItem value="Powershell" label="Windows-PS"> |
| 91 | + |
| 92 | +```bash |
| 93 | +$Env:PROJECT_TOKEN="123456#1234abcd-****-****-****-************" |
| 94 | +``` |
| 95 | +</TabItem> |
| 96 | +</Tabs> |
| 97 | + |
| 98 | +### **Step 3:** Execute Tests with custom Build Names |
| 99 | + |
| 100 | +You can add a custom build name by adding the `--buildName` flag to your test execution command. Here are different ways to use this feature: |
| 101 | + |
| 102 | +#### Custom Build Name (Expected Usage) |
| 103 | +Specify a custom build name to group your screenshots in the following way: |
| 104 | + |
| 105 | +```bash |
| 106 | +npx smartui --config .smartui.json exec --buildName "Sample Build Name" -- <execution-command> |
| 107 | +``` |
| 108 | +>**Example:** |
| 109 | + For a `Node.js` test script : |
| 110 | +>```bash |
| 111 | +>npx smartui --config .smartui.json exec --buildName "Sample Build Name" -- node test.js |
| 112 | +>``` |
| 113 | +
|
| 114 | +#### Default Usage |
| 115 | +If no buildname is specified, a random build name is added to the builds: |
| 116 | +
|
| 117 | +```bash |
| 118 | +npx smartui --config .smartui.json exec -- <execution-command> |
| 119 | +``` |
| 120 | +
|
| 121 | +### **Step 4:** Advanced Use Case |
| 122 | + |
| 123 | +If you are running multiple test cases in a single job (e.g., using HyperExecute) and want to club all screenshots under a single build while maintaining consistent Git baseline management, you can do the following: |
| 124 | + |
| 125 | +This can be done as follows: |
| 126 | + |
| 127 | +```bash |
| 128 | +npx smartui --config .smartui.json exec --buildName $env:JOB_ID -- node test.js |
| 129 | +``` |
| 130 | +##### This approach ensures: |
| 131 | + |
| 132 | +- A new build is created for every HyperExecute job. |
| 133 | +- Screenshots from all tests in the same job are appended to the same build. |
| 134 | +- Git branching strategies remain unaffected, improving baseline management across branches. |
| 135 | + |
| 136 | + |
| 137 | +>## Key Benefits |
| 138 | +>1. Efficient grouping of screenshots by build names. |
| 139 | +>2. Seamless integration with Git baseline management. |
| 140 | +>3. Flexibility to append screenshots to existing builds. |
| 141 | +>4. Optimized workflows for parallel and single-job executions. |
| 142 | +
|
| 143 | + |
| 144 | +<nav aria-label="breadcrumbs"> |
| 145 | + <ul className="breadcrumbs"> |
| 146 | + <li className="breadcrumbs__item"> |
| 147 | + <a className="breadcrumbs__link" target="_self" href="https://www.lambdatest.com"> |
| 148 | + Home |
| 149 | + </a> |
| 150 | + </li> |
| 151 | + <li className="breadcrumbs__item"> |
| 152 | + <a className="breadcrumbs__link" target="_self" href="https://www.lambdatest.com/support/docs/"> |
| 153 | + Support |
| 154 | + </a> |
| 155 | + </li> |
| 156 | + <li className="breadcrumbs__item breadcrumbs__item--active"> |
| 157 | + <span className="breadcrumbs__link"> Smart UI with Cypress </span> |
| 158 | + </li> |
| 159 | + </ul> |
| 160 | +</nav> |
0 commit comments