Skip to content

Commit

Permalink
[WDIO] Fix missing custom ID support in WDIO (#161)
Browse files Browse the repository at this point in the history
Co-authored-by: Logan Graham <[email protected]>
  • Loading branch information
omacranger and Logan Graham authored Nov 14, 2024
1 parent 312753a commit cef6b06
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
5 changes: 5 additions & 0 deletions visual-js/.changeset/unlucky-poems-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saucelabs/wdio-sauce-visual-service": patch
---

auto append custom id when creating build in wdio
19 changes: 8 additions & 11 deletions visual-js/visual-wdio/src/SauceVisualService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
getVisualResults,
isIgnoreSelectorType,
IgnoreSelectorIn,
getEnvOpts,
} from '@saucelabs/visual';

import logger from '@wdio/logger';
Expand All @@ -44,13 +45,7 @@ const log = logger('@saucelabs/wdio-sauce-visual-service');

const VISUAL_BUILD_ID_KEY = 'SAUCE_VISUAL_BUILD_ID';

const {
SAUCE_VISUAL_PROJECT,
SAUCE_VISUAL_BRANCH,
SAUCE_VISUAL_DEFAULT_BRANCH,
SAUCE_VISUAL_BUILD_NAME,
SAUCE_VISUAL_CUSTOM_ID,
} = process.env;
const { SAUCE_VISUAL_BUILD_NAME, SAUCE_VISUAL_CUSTOM_ID } = process.env;

type ResultStatus = Record<DiffStatus, number>;

Expand Down Expand Up @@ -89,6 +84,7 @@ export type SauceVisualServiceOptions = {
buildId?: string;
project?: string;
branch?: string;
customId?: string;
defaultBranch?: string;
diffingMethod?: DiffingMethod;
captureDom?: boolean;
Expand Down Expand Up @@ -208,16 +204,17 @@ export default class SauceVisualService implements Services.ServiceInstance {
isBuildExternal = true;
} else {
let build;
const { customId, defaultBranch, branch, project } = getEnvOpts();
try {
build = await this.apiClient.createBuild({
name:
this.options.buildName ||
SAUCE_VISUAL_BUILD_NAME ||
'WebdriverIO Visual Testing',
project: this.options.project || SAUCE_VISUAL_PROJECT || null,
branch: this.options.branch || SAUCE_VISUAL_BRANCH || null,
defaultBranch:
this.options.defaultBranch || SAUCE_VISUAL_DEFAULT_BRANCH || null,
project: this.options.project || project,
branch: this.options.branch || branch,
defaultBranch: this.options.defaultBranch || defaultBranch,
customId: this.options.customId || customId,
});
} catch (e: unknown) {
const errorMessage = ensureError(e).message ?? 'Unknown error';
Expand Down
4 changes: 2 additions & 2 deletions visual-js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3094,7 +3094,7 @@ __metadata:
languageName: unknown
linkType: soft

"@saucelabs/visual@^0.10.0, @saucelabs/visual@workspace:visual":
"@saucelabs/visual@^0.10.0, @saucelabs/visual@^0.10.1, @saucelabs/visual@workspace:visual":
version: 0.0.0-use.local
resolution: "@saucelabs/visual@workspace:visual"
dependencies:
Expand Down Expand Up @@ -3141,7 +3141,7 @@ __metadata:
resolution: "@saucelabs/wdio-sauce-visual-service@workspace:visual-wdio"
dependencies:
"@jest/globals": ^29.7.0
"@saucelabs/visual": ^0.10.0
"@saucelabs/visual": ^0.10.1
"@tsconfig/node18": ^2.0.0
"@types/jest": ^29.5.6
"@typescript-eslint/eslint-plugin": ^5.59.1
Expand Down

0 comments on commit cef6b06

Please sign in to comment.