Skip to content

Remove default smartui server address #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/playwright/src/smartui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const utils = require('@lambdatest/sdk-utils');
const pkgName = require('../package.json').name;

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

let log = utils.logger(pkgName);

Expand All @@ -25,11 +25,11 @@ async function smartuiSnapshot(page, snapshotName, options) {
let { body } = await utils.postSnapshot({
dom,
url: page.url(),
name: snapshotName,
name,
options
}, pkgName);

log.info(`Snapshot captured: ${snapshotName}`);
log.info(`Snapshot captured: ${name}`);

if (body && body.data && body.data.warnings?.length !== 0) body.data.warnings.map(e => log.warn(e));
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions packages/puppeteer/src/smartui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const pkgName = require('../package.json').name;

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

let log = utils.logger(pkgName);

Expand Down
3 changes: 2 additions & 1 deletion packages/sdk-utils/src/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function getSmartUIServerAddress() {
return process.env.SMARTUI_SERVER_ADDRESS || 'http://localhost:8080'
if (!process.env.SMARTUI_SERVER_ADDRESS) throw new Error('SmartUI server address not found');
return process.env.SMARTUI_SERVER_ADDRESS
}

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions packages/selenium-driver/src/smartui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const pkgName = require('../package.json').name;
async function smartuiSnapshot(driver, name, options = {}) {
// TODO: check if driver is selenium webdriver object
if (!driver) throw new Error('An instance of the selenium driver object is required.');
if (!name) throw new Error('The `name` argument is required.');
if (!(await utils.isSmartUIRunning())) throw new Error('SmartUI server is not running.');
if (!name || typeof name !== 'string') throw new Error('The `name` argument is required.');
if (!(await utils.isSmartUIRunning())) throw new Error('Cannot find SmartUI server.');
let log = utils.logger(pkgName);

try {
Expand Down
10 changes: 5 additions & 5 deletions packages/testcafe/src/smartui.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const utils = require('@lambdatest/sdk-utils');
const pkgName = require('../package.json').name;

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

let log = utils.logger(pkgName);

Expand All @@ -26,11 +26,11 @@ async function smartuiSnapshot(t, snapshotName, options) {
let { body } = await utils.postSnapshot({
dom: dom,
url,
name: snapshotName,
name,
options
}, pkgName);

log.info(`Snapshot captured: ${snapshotName}`);
log.info(`Snapshot captured: ${name}`);

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