Skip to content

Commit 4a1ecf2

Browse files
authored
Merge pull request LambdaTest#1181 from JeeveshJ7/stage
SmartUI CLI Build Name
2 parents 8bb0431 + f714aef commit 4a1ecf2

File tree

3 files changed

+189
-0
lines changed

3 files changed

+189
-0
lines changed

docs/smartui-cli-build-name.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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>

docs/smartui-cli-upload.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,19 @@ Specify a custom filename for your results:
182182
```bash
183183
npx smartui upload <directoryName> --fetch-results custom-results.json
184184
```
185+
### Adding a custom build name
186+
You can add a custom build name by adding the `--buildName` flag to your test execution command. Here is how you can utilise this feature:
187+
188+
Specify a custom build name to group your screenshots in the following way:
189+
190+
```bash
191+
npx smartui upload <directoryName> --buildName "Sample Build Name"
192+
```
193+
194+
> Note:
195+
> - If no build name is provided, a random name will be automatically assigned to the build.
196+
> - Specifying the name of an existing build within the project will append the screenshots to that build.
197+
> - Existing screenshots with the same name and configuration in the build will be overwritten during a re-run.
185198

186199
<img loading="lazy" src={require('../assets/images/smart-visual-testing/smartui-sdk-results-primer.webp').default} alt="cmd" width="768" height="373" className="doc_img"/>
187200

docs/smartui-cli.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,22 @@ Specify a custom filename for your results:
238238
```bash
239239
npx smartui capture urls.json --config .smartui.json --fetch-results custom-results.json
240240
```
241+
242+
### Adding a custom build name
243+
You can add a custom build name by adding the `--buildName` flag to your test execution command. Here is how you can utilise this feature:
244+
245+
Specify a custom build name to group your screenshots in the following way:
246+
247+
```bash
248+
npx smartui capture urls.json --buildName "Sample Build Name" --config .smartui.json
249+
```
250+
251+
> Note:
252+
> - If no build name is provided, a random name will be automatically assigned to the build.
253+
> - Specifying the name of an existing build within the project will append the screenshots to that build.
254+
> - Existing screenshots with the same name and configuration in the build will be overwritten during a re-run.
255+
256+
241257
### Setup with Continuous Integration (CI)
242258

243259
If you are using the Continuous Integration (CI) pipeline for your application and want to integrate `SmartUI CLI` execution then the following are the steps needs to be added to your `.yaml` file:

0 commit comments

Comments
 (0)