diff --git a/core/logger/src/logger-server.ts b/core/logger/src/logger-server.ts index 275758e4b..ed75909c3 100644 --- a/core/logger/src/logger-server.ts +++ b/core/logger/src/logger-server.ts @@ -56,7 +56,7 @@ export class LoggerServer extends PluggableModule implements ILoggerServer { ): Promise { const queueItem = this.queue.shift(); - if (queueItem === undefined) { + if (!queueItem) { this.status = LogQueueStatus.EMPTY; return; } diff --git a/core/types/src/utils/index.ts b/core/types/src/utils/index.ts index 38a7665c4..a3f375b7d 100644 --- a/core/types/src/utils/index.ts +++ b/core/types/src/utils/index.ts @@ -13,7 +13,7 @@ export interface IStack { export interface IQueue { push(...elements: Array): void; - shift(): T | void; + shift(): T | undefined; clean(): void; diff --git a/core/utils/src/queue.ts b/core/utils/src/queue.ts index 03168fa5c..6620eb67d 100644 --- a/core/utils/src/queue.ts +++ b/core/utils/src/queue.ts @@ -15,7 +15,7 @@ export class Queue implements IQueue { this.array.push(...elements); } - public shift(): T | void { + public shift(): T | undefined { return this.array.shift(); } diff --git a/packages/web-application/src/web-application.ts b/packages/web-application/src/web-application.ts index c5e03b9f1..49bc89d83 100644 --- a/packages/web-application/src/web-application.ts +++ b/packages/web-application/src/web-application.ts @@ -19,6 +19,7 @@ import { XpathSelector, ShadowCssSelector, Selector, + isXpathSelector, } from '@testring/types'; import {asyncBreakpoints} from '@testring/async-breakpoints'; @@ -225,12 +226,18 @@ export class WebApplication extends PluggableModule { if (this.config.devtool) { try { - if (normalizedXPath && normalizedXPath.type !== 'xpath') { - throw new Error( - `devtoolHighlight only supports xpath selectors. Received type: ${normalizedXPath.type}, value: ${JSON.stringify(normalizedXPath)}` - ); + let xpathString: string | null = null; + + if (normalizedXPath) { + if (!isXpathSelector(normalizedXPath)) { + throw new Error( + `devtoolHighlight only supports xpath selectors. Received type: ${normalizedXPath.type}, value: ${JSON.stringify(normalizedXPath)}` + ); + } + + xpathString = normalizedXPath.xpath; } - const xpathString = normalizedXPath ? normalizedXPath.xpath : null; + await this.client.execute((addHighlightXpath: string) => { window.postMessage( {