Skip to content

Commit d755910

Browse files
committed
plop
1 parent f67f623 commit d755910

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

packages/ocr-service/src/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class WdioOcrService {
6262
const self = this
6363
log.info(`Adding commands to Multi Browser: ${browserNames.join(', ')}`)
6464
/**
65-
* Add all OCR commands to the global browser object that will execute
65+
* Add all commands to the global browser object that will execute on each browser in the Multi Remote.
6666
*/
6767
for (const commandName of Object.keys(ocrCommands)) {
6868
browser.addCommand(commandName, async function (...args: unknown[]) {
@@ -92,7 +92,7 @@ export default class WdioOcrService {
9292
})
9393
}
9494
/**
95-
* Add all OCR commands to each instance (but Single Remote version)
95+
* Add all commands to each instance (but Single Remote version)
9696
*/
9797
for (const browserName of browserNames) {
9898
const multiremoteBrowser = browser as WebdriverIO.MultiRemoteBrowser

packages/visual-reporter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"build": "run-s clean build:*",
1818
"build:report": "remix vite:build",
1919
"build:scripts": "tsc -p tsconfig.scripts.json",
20-
"clean": "rimraf coverage build *.tsbuildinfo",
20+
"clean": "rimraf coverage build --glob *.tsbuildinfo",
2121
"dev": "cross-env VISUAL_REPORT_LOCAL_DEV=true run-s build:scripts script:prepare.report && run-p watch:scripts dev:remix",
2222
"dev:remix": "remix vite:dev",
2323
"script:prepare.report": "node ./dist/prepareReportAssets.js",

packages/visual-service/src/service.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import logger from '@wdio/logger'
22
import { expect } from '@wdio/globals'
33
import { dirname, normalize, resolve } from 'node:path'
44
import type { Capabilities, Frameworks } from '@wdio/types'
5+
import type { TransformElement } from 'webdriverio'
56
import {
67
BaseClass,
78
checkElement,
@@ -142,7 +143,14 @@ export default class WdioImageComparisonService extends BaseClass {
142143
const browserNames = Object.keys(capabilities)
143144

144145
/**
145-
* Add all the commands to each browser in the Multi Remote
146+
* Add all commands to the global browser object that will execute on each browser in the Multi Remote.
147+
*/
148+
for (const [commandName, command] of Object.entries(pageCommands)) {
149+
this.#addMultiremoteCommand(browser, browserNames, commandName, command)
150+
}
151+
152+
/**
153+
* Add all commands to each instance (but Single Remote version)
146154
*/
147155
for (const browserName of browserNames) {
148156
log.info(`Adding commands to Multi Browser: ${browserName}`)
@@ -155,15 +163,6 @@ export default class WdioImageComparisonService extends BaseClass {
155163
await this.#addCommandsToBrowser(browserInstance)
156164
}
157165

158-
/**
159-
* Add all the commands to the global browser object that will execute
160-
* on each browser in the Multi Remote
161-
* Start with the page commands
162-
*/
163-
for (const [commandName, command] of Object.entries(pageCommands)) {
164-
this.#addMultiremoteCommand(browser, browserNames, commandName, command)
165-
}
166-
167166
/**
168167
* Add all the element commands to the global browser object that will execute
169168
* on each browser in the Multi Remote
@@ -234,7 +233,7 @@ export default class WdioImageComparisonService extends BaseClass {
234233
methods: {
235234
bidiScreenshot: isBiDiScreenshotSupported(browser) ? this.browsingContextCaptureScreenshot.bind(browser) : undefined,
236235
executor: <ReturnValue, InnerArguments extends unknown[]>(
237-
fn: string | ((...args: InnerArguments) => ReturnValue),
236+
fn: string | ((...innerArgs: TransformElement<InnerArguments>) => ReturnValue),
238237
...args: InnerArguments
239238
): Promise<ReturnValue> => {
240239
return this.execute(fn, ...args) as Promise<ReturnValue>
@@ -311,7 +310,7 @@ export default class WdioImageComparisonService extends BaseClass {
311310
methods: {
312311
bidiScreenshot: isBiDiScreenshotSupported(browser) ? this.browsingContextCaptureScreenshot.bind(browser) : undefined,
313312
executor: <ReturnValue, InnerArguments extends unknown[]>(
314-
fn: string | ((...args: InnerArguments) => ReturnValue),
313+
fn: string | ((...innerArgs: TransformElement<InnerArguments>) => ReturnValue),
315314
...args: InnerArguments
316315
): Promise<ReturnValue> => {
317316
return this.execute(fn, ...args) as Promise<ReturnValue>
@@ -387,7 +386,7 @@ export default class WdioImageComparisonService extends BaseClass {
387386
methods: {
388387
bidiScreenshot: isBiDiScreenshotSupported(browserInstance) ? browserInstance.browsingContextCaptureScreenshot.bind(browserInstance) : undefined,
389388
executor: <ReturnValue, InnerArguments extends unknown[]>(
390-
fn: string | ((...args: InnerArguments) => ReturnValue),
389+
fn: string | ((...innerArgs: TransformElement<InnerArguments>) => ReturnValue),
391390
...args: InnerArguments
392391
): Promise<ReturnValue> => {
393392
return browserInstance.execute(fn, ...args) as Promise<ReturnValue>
@@ -480,7 +479,7 @@ export default class WdioImageComparisonService extends BaseClass {
480479
methods: {
481480
bidiScreenshot: isBiDiScreenshotSupported(browserInstance) ? browserInstance.browsingContextCaptureScreenshot.bind(browserInstance) : undefined,
482481
executor: <ReturnValue, InnerArguments extends unknown[]>(
483-
fn: string | ((...args: InnerArguments) => ReturnValue),
482+
fn: string | ((...innerArgs: TransformElement<InnerArguments>) => ReturnValue),
484483
...args: InnerArguments
485484
): Promise<ReturnValue> => {
486485
return browserInstance.execute(fn, ...args) as Promise<ReturnValue>

packages/visual-service/src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Capabilities } from '@wdio/types'
22
import type { AppiumCapabilities } from 'node_modules/@wdio/types/build/Capabilities.js'
33
import { getMobileScreenSize, getMobileViewPortPosition, IOS_OFFSETS, NOT_KNOWN } from 'webdriver-image-comparison'
44
import type { Folders, InstanceData, TestContext } from 'webdriver-image-comparison'
5+
import type { TransformElement, TransformReturn } from 'webdriverio'
56
import type {
67
EnrichTestContextOptions,
78
getFolderMethodOptions,
@@ -70,8 +71,8 @@ async function getMobileInstanceData({
7071

7172
if (isMobile) {
7273
const executor = <ReturnValue, InnerArguments extends unknown[]>(
73-
fn: string | ((...args: InnerArguments) => ReturnValue),
74-
...args: InnerArguments) => currentBrowser.execute(fn, ...args) as Promise<ReturnValue>
74+
fn: string | ((...innerArgs: TransformElement<InnerArguments>) => ReturnValue),
75+
...args: InnerArguments) => currentBrowser.execute(fn, ...args) as Promise<TransformReturn<ReturnValue>>
7576
const getUrl = () => currentBrowser.getUrl()
7677
const url = (arg:string) => currentBrowser.url(arg)
7778
const currentDriverCapabilities = currentBrowser.capabilities

packages/webdriver-image-comparison/src/methods/methods.interfaces.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import type { RectanglesOutput } from './rectangles.interfaces.js'
2-
2+
import type { TransformReturn, TransformElement } from 'webdriverio'
33
// There a multiple ways to call the executor method, for mobile and web
4-
type ExecuteScript = <ReturnValue, Args extends unknown[]>(
5-
fn: (...args: Args) => ReturnValue,
6-
...args: Args
7-
) => Promise<ReturnValue>;
4+
type ExecuteScript = <ReturnValue, InnerArguments extends unknown[]>(
5+
fn: (...innerArgs: TransformElement<InnerArguments>) => ReturnValue,
6+
...args: InnerArguments
7+
) => Promise<TransformReturn<ReturnValue>>;
88

99
type ExecuteMobile = <ReturnValue>(
1010
fn: string,
1111
args?: Record<string, any>
12-
) => Promise<ReturnValue>;
12+
) => Promise<TransformReturn<ReturnValue>>;
1313
interface BrowsingContextCaptureScreenshotParameters {
1414
context: string;
1515
origin?: 'viewport' | 'document';

0 commit comments

Comments
 (0)