Skip to content

Commit d10131b

Browse files
authored
Merge pull request #21 from pinanks/minor-fixes
Remove default smartui server address
2 parents 6c84682 + ac83b1c commit d10131b

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

packages/playwright/src/smartui.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ const utils = require('@lambdatest/sdk-utils');
22
const pkgName = require('../package.json').name;
33

44
// Take a DOM snapshot and post it to the snapshot endpoint
5-
async function smartuiSnapshot(page, snapshotName, options) {
5+
async function smartuiSnapshot(page, name, options) {
66
if (!page) throw new Error('A Playwright `page` object is required.');
7-
if (!snapshotName) throw new Error('The `name` argument is required.');
8-
if (!(await utils.isSmartUIRunning())) throw new Error('SmartUI server is not running.');
7+
if (!name || typeof name !== 'string') throw new Error('The `name` argument is required.');
8+
if (!(await utils.isSmartUIRunning())) throw new Error('Cannot find SmartUI server.');
99

1010
let log = utils.logger(pkgName);
1111

@@ -25,11 +25,11 @@ async function smartuiSnapshot(page, snapshotName, options) {
2525
let { body } = await utils.postSnapshot({
2626
dom,
2727
url: page.url(),
28-
name: snapshotName,
28+
name,
2929
options
3030
}, pkgName);
3131

32-
log.info(`Snapshot captured: ${snapshotName}`);
32+
log.info(`Snapshot captured: ${name}`);
3333

3434
if (body && body.data && body.data.warnings?.length !== 0) body.data.warnings.map(e => log.warn(e));
3535
} catch (err) {

packages/puppeteer/src/smartui.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const pkgName = require('../package.json').name;
44

55
async function smartuiSnapshot(page, name, options = {}) {
66
if (!page) throw new Error('puppeteer `page` argument is required.');
7-
if (!name) throw new Error('The `name` argument is required.');
8-
if (!(await utils.isSmartUIRunning())) throw new Error('SmartUI server is not running.');
7+
if (!name || typeof name !== 'string') throw new Error('The `name` argument is required.');
8+
if (!(await utils.isSmartUIRunning())) throw new Error('Cannot find SmartUI server.');
99

1010
let log = utils.logger(pkgName);
1111

packages/sdk-utils/src/lib/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
function getSmartUIServerAddress() {
2-
return process.env.SMARTUI_SERVER_ADDRESS || 'http://localhost:8080'
2+
if (!process.env.SMARTUI_SERVER_ADDRESS) throw new Error('SmartUI server address not found');
3+
return process.env.SMARTUI_SERVER_ADDRESS
34
}
45

56
module.exports = {

packages/selenium-driver/src/smartui.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const pkgName = require('../package.json').name;
44
async function smartuiSnapshot(driver, name, options = {}) {
55
// TODO: check if driver is selenium webdriver object
66
if (!driver) throw new Error('An instance of the selenium driver object is required.');
7-
if (!name) throw new Error('The `name` argument is required.');
8-
if (!(await utils.isSmartUIRunning())) throw new Error('SmartUI server is not running.');
7+
if (!name || typeof name !== 'string') throw new Error('The `name` argument is required.');
8+
if (!(await utils.isSmartUIRunning())) throw new Error('Cannot find SmartUI server.');
99
let log = utils.logger(pkgName);
1010

1111
try {

packages/testcafe/src/smartui.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const utils = require('@lambdatest/sdk-utils');
22
const pkgName = require('../package.json').name;
33

4-
async function smartuiSnapshot(t, snapshotName, options) {
4+
async function smartuiSnapshot(t, name, options) {
55
if (!t) throw new Error("The test function's `t` argument is required.");
6-
if (!snapshotName) throw new Error('The `name` argument is required.');
7-
if (!(await utils.isSmartUIRunning())) throw new Error('SmartUI server is not running.');
6+
if (!name || typeof name !== 'string') throw new Error('The `name` argument is required.');
7+
if (!(await utils.isSmartUIRunning())) throw new Error('Cannot find SmartUI server.');
88

99
let log = utils.logger(pkgName);
1010

@@ -26,11 +26,11 @@ async function smartuiSnapshot(t, snapshotName, options) {
2626
let { body } = await utils.postSnapshot({
2727
dom: dom,
2828
url,
29-
name: snapshotName,
29+
name,
3030
options
3131
}, pkgName);
3232

33-
log.info(`Snapshot captured: ${snapshotName}`);
33+
log.info(`Snapshot captured: ${name}`);
3434

3535
if (body && body.data && body.data.warnings?.length !== 0) body.data.warnings.map(e => log.warn(e));
3636
} catch (error) {

0 commit comments

Comments
 (0)