Skip to content
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
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default wdioEslint.config([
{
ignores: [
'lib',
'types'
'**/*/dist'
]
},
/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"clean": "run-p clean:*",
"clean:build": "rimraf ./lib",
"clean:tests": "rimraf test-types/**/node_modules && rimraf test-types/**/dist",
"compile": "tsc --build tsconfig.build.json",
"compile": "tsc --build tsconfig.json",
"test": "run-s test:*",
"test:lint": "eslint .",
"test:unit": "vitest --run",
Expand Down
1 change: 0 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const waitUntil = async (
// wait for condition to be truthy
try {
const start = Date.now()
// eslint-disable-next-line no-constant-condition
while (true) {
if (Date.now() - start > wait) {
throw new Error('timeout')
Expand Down
1 change: 1 addition & 0 deletions test/matchers/mock/toBeRequested.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { vi, test, describe, expect } from 'vitest'
// @ts-ignore TODO fix me
import type { Matches, Mock } from 'webdriverio'

import { toBeRequested } from '../../../src/matchers/mock/toBeRequested.js'
Expand Down
1 change: 1 addition & 0 deletions test/matchers/mock/toBeRequestedTimes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { vi, test, describe, expect } from 'vitest'
// @ts-ignore TODO fix me
import type { Matches, Mock } from 'webdriverio'

import { toBeRequestedTimes } from '../../../src/matchers/mock/toBeRequestedTimes.js'
Expand Down
4 changes: 2 additions & 2 deletions test/util/elementsUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ vi.mock('@wdio/globals')
describe('elementsUtil', () => {
describe('wrapExpectedWithArray', () => {
test('is not array ', async () => {
const el = await $('sel')
const el = (await $('sel')) as unknown as WebdriverIO.Element
const actual = wrapExpectedWithArray(el, 'Test Actual', 'Test Expected')
expect(actual).toEqual('Test Expected')
})

test('is array ', async () => {
const els = await $$('sel')
const els = (await $$('sel')) as unknown as WebdriverIO.ElementArray
const actual = wrapExpectedWithArray(els, ['Test Actual', 'Test Actual'], 'Test Expected')
expect(actual).toEqual(['Test Expected'])
})
Expand Down
2 changes: 1 addition & 1 deletion test/util/refetchElements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('refetchElements', () => {
let els: WebdriverIO.ElementArray

beforeEach(async () => {
els = await $$('parent')
els = (await $$('parent')) as unknown as WebdriverIO.ElementArray
// @ts-ignore
els.parent._length = 5
})
Expand Down
6 changes: 0 additions & 6 deletions tsconfig.build.json

This file was deleted.

65 changes: 38 additions & 27 deletions types/expect-webdriverio.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
type ServiceInstance = import('@wdio/types').Services.ServiceInstance;
type Test = import('@wdio/types').Frameworks.Test;
type TestResult = import('@wdio/types').Frameworks.TestResult;
type PickleStep = import('@wdio/types').Frameworks.PickleStep;
type Scenario = import('@wdio/types').Frameworks.Scenario;
type SnapshotResult = import('@vitest/snapshot').SnapshotResult;
type SnapshotUpdateState = import('@vitest/snapshot').SnapshotUpdateState;
/* eslint-disable @typescript-eslint/consistent-type-imports*/
type ServiceInstance = import('@wdio/types').Services.ServiceInstance
type Test = import('@wdio/types').Frameworks.Test
type TestResult = import('@wdio/types').Frameworks.TestResult
type PickleStep = import('@wdio/types').Frameworks.PickleStep
type Scenario = import('@wdio/types').Frameworks.Scenario
type SnapshotResult = import('@vitest/snapshot').SnapshotResult
type SnapshotUpdateState = import('@vitest/snapshot').SnapshotUpdateState

declare namespace ExpectWebdriverIO {
const expect: ExpectWebdriverIO.Expect
function setOptions(options: DefaultOptions): void
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function getConfig(): any

interface SnapshotServiceArgs {
Expand All @@ -23,32 +25,34 @@ declare namespace ExpectWebdriverIO {
}

interface SoftFailure {
error: Error;
matcherName: string;
location?: string;
error: Error
matcherName: string
location?: string
}

class SoftAssertService {
static getInstance(): SoftAssertService;
setCurrentTest(testId: string, testName?: string, testFile?: string): void;
clearCurrentTest(): void;
getCurrentTestId(): string | null;
addFailure(error: Error, matcherName: string): void;
getFailures(testId?: string): SoftFailure[];
clearFailures(testId?: string): void;
assertNoFailures(testId?: string): void;
static getInstance(): SoftAssertService
setCurrentTest(testId: string, testName?: string, testFile?: string): void
clearCurrentTest(): void
getCurrentTestId(): string | null
addFailure(error: Error, matcherName: string): void
getFailures(testId?: string): SoftFailure[]
clearFailures(testId?: string): void
assertNoFailures(testId?: string): void
}

interface SoftAssertionServiceOptions {
autoAssertOnTestEnd?: boolean;
autoAssertOnTestEnd?: boolean
}

class SoftAssertionService implements ServiceInstance {
constructor(serviceOptions?: SoftAssertionServiceOptions, capabilities?: any, config?: any);
beforeTest(test: Test): void;
beforeStep(step: PickleStep, scenario: Scenario): void;
afterTest(test: Test, context: any, result: TestResult): void;
afterStep(step: PickleStep, scenario: Scenario, result: { passed: boolean, error?: Error }): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(serviceOptions?: SoftAssertionServiceOptions, capabilities?: any, config?: any)
beforeTest(test: Test): void
beforeStep(step: PickleStep, scenario: Scenario): void
// eslint-disable-next-line @typescript-eslint/no-explicit-any
afterTest(test: Test, context: any, result: TestResult): void
afterStep(step: PickleStep, scenario: Scenario, result: { passed: boolean, error?: Error }): void
}

interface AssertionResult {
Expand All @@ -59,7 +63,9 @@ declare namespace ExpectWebdriverIO {
const matchers: Map<
string,
(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
actual: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...expected: any[]
) => Promise<AssertionResult>
>
Expand All @@ -79,6 +85,7 @@ declare namespace ExpectWebdriverIO {
* expect(el).toHaveAttribute('attr', 'value', { ... }) // expectedValue is `['attr', 'value]`
* ```
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expectedValue?: any,
/**
* Options that the user has passed in, e.g. `expect(el).toHaveText('foo', { ignoreCase: true })` -> `{ ignoreCase: true }`
Expand Down Expand Up @@ -238,10 +245,10 @@ declare namespace ExpectWebdriverIO {
* **Usage**
* ```js
* // Check if an element has the class 'btn'
* await expect(element).toHaveElementClass('btn');
* await expect(element).toHaveElementClass('btn')
*
* // Check if an element has any of the specified classes
* await expect(element).toHaveElementClass(['btn', 'btn-large']);
* await expect(element).toHaveElementClass(['btn', 'btn-large'])
* ```
*/
toHaveElementClass(className: string | RegExp | Array<string | RegExp> | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
Expand All @@ -251,6 +258,7 @@ declare namespace ExpectWebdriverIO {
*/
toHaveElementProperty(
property: string | RegExp | ExpectWebdriverIO.PartialMatcher,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value?: any,
options?: ExpectWebdriverIO.StringOptions
): R
Expand Down Expand Up @@ -418,7 +426,7 @@ declare namespace ExpectWebdriverIO {
toBeElementsArrayOfSize(
size: number | ExpectWebdriverIO.NumberOptions,
options?: ExpectWebdriverIO.NumberOptions
): R & Promise<WebdriverIO.ElementArray>;
): R & Promise<WebdriverIO.ElementArray>

// ==== network mock ====
/**
Expand Down Expand Up @@ -479,8 +487,10 @@ declare namespace ExpectWebdriverIO {
type JsonCompatible = jsonObject | jsonArray

interface PartialMatcher {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sample?: any
$$typeof: symbol
// eslint-disable-next-line @typescript-eslint/no-explicit-any
asymmetricMatch(...args: any[]): boolean
toString(): string
}
Expand Down Expand Up @@ -527,6 +537,7 @@ declare namespace ExpectWebdriverIO {
}

interface AsymmetricMatchers {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
any(expectedObject: any): PartialMatcher
anything(): PartialMatcher
arrayContaining(sample: Array<unknown>): PartialMatcher
Expand Down
2 changes: 2 additions & 0 deletions types/standalone.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/consistent-type-imports*/
/// <reference types="./expect-webdriverio.js"/>

type ChainablePromiseElement = import('webdriverio').ChainablePromiseElement<WebdriverIO.Element>
Expand All @@ -21,6 +22,7 @@ declare namespace ExpectWebdriverIO {
} & AsymmetricMatchers

interface AsymmetricMatchers {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
any(expectedObject: any): PartialMatcher
anything(): PartialMatcher
arrayContaining(sample: Array<unknown>): PartialMatcher
Expand Down
6 changes: 3 additions & 3 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export default defineConfig({
],
thresholds: {
lines: 87,
functions: 85,
branches: 88,
statements: 87
functions: 86,
statements: 87,
branches: 88
}
}
}
Expand Down