expect-webdriverio 5.3.4 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/jasmine.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { executeCommandBe } from '../../utils.js';
|
|
2
2
|
import { DEFAULT_OPTIONS } from '../../constants.js';
|
|
3
|
-
export async function toBeDisplayed(received, options = DEFAULT_OPTIONS) {
|
|
3
|
+
export async function toBeDisplayed(received, { withinViewport = false, contentVisibilityAuto = true, opacityProperty = true, visibilityProperty = true } = {}, options = DEFAULT_OPTIONS) {
|
|
4
4
|
this.expectation = this.expectation || 'displayed';
|
|
5
5
|
await options.beforeAssertion?.({
|
|
6
6
|
matcherName: 'toBeDisplayed',
|
|
7
7
|
options,
|
|
8
8
|
});
|
|
9
|
-
const result = await executeCommandBe.call(this, received, el => el?.isDisplayed(), options);
|
|
9
|
+
const result = await executeCommandBe.call(this, received, el => el?.isDisplayed({ withinViewport, contentVisibilityAuto, opacityProperty, visibilityProperty }), options);
|
|
10
10
|
await options.afterAssertion?.({
|
|
11
11
|
matcherName: 'toBeDisplayed',
|
|
12
12
|
options,
|
|
@@ -35,7 +35,7 @@ export async function toHaveAttributeAndValue(received, attribute, value, option
|
|
|
35
35
|
async function toHaveAttributeFn(received, attribute) {
|
|
36
36
|
const isNot = this.isNot;
|
|
37
37
|
const { expectation = 'attribute', verb = 'have' } = this;
|
|
38
|
-
let el = await received;
|
|
38
|
+
let el = await received?.getElement();
|
|
39
39
|
const pass = await waitUntil(async () => {
|
|
40
40
|
const result = await executeCommand.call(this, el, conditionAttr, {}, [attribute]);
|
|
41
41
|
el = result.el;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expect-webdriverio",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
|
|
5
5
|
"description": "WebdriverIO Assertion Library",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,10 +46,12 @@
|
|
|
46
46
|
"clean:build": "rimraf ./lib",
|
|
47
47
|
"clean:tests": "rimraf test-types/**/node_modules && rimraf test-types/**/dist",
|
|
48
48
|
"compile": "tsc --build tsconfig.build.json",
|
|
49
|
+
"tsc:root-types": "tsc jasmine.d.ts jest.d.ts",
|
|
49
50
|
"test": "run-s test:*",
|
|
51
|
+
"test:tsc": "tsc --project tsconfig.json --noEmit",
|
|
50
52
|
"test:lint": "eslint .",
|
|
51
53
|
"test:unit": "vitest --run",
|
|
52
|
-
"test:types": "node test-types/copy && npm run ts && npm run clean:tests",
|
|
54
|
+
"test:types": "node test-types/copy && npm run ts && npm run clean:tests && npm run tsc:root-types",
|
|
53
55
|
"ts": "run-s ts:*",
|
|
54
56
|
"ts:default": "cd test-types/default && tsc -p ./tsconfig.json --incremental",
|
|
55
57
|
"ts:jest": "cd test-types/jest && tsc -p ./tsconfig.json --incremental",
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
type
|
|
4
|
-
type
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
1
|
+
/* eslint-disable @typescript-eslint/consistent-type-imports*/
|
|
2
|
+
type ServiceInstance = import('@wdio/types').Services.ServiceInstance
|
|
3
|
+
type Test = import('@wdio/types').Frameworks.Test
|
|
4
|
+
type TestResult = import('@wdio/types').Frameworks.TestResult
|
|
5
|
+
type PickleStep = import('@wdio/types').Frameworks.PickleStep
|
|
6
|
+
type Scenario = import('@wdio/types').Frameworks.Scenario
|
|
7
|
+
type SnapshotResult = import('@vitest/snapshot').SnapshotResult
|
|
8
|
+
type SnapshotUpdateState = import('@vitest/snapshot').SnapshotUpdateState
|
|
8
9
|
|
|
9
10
|
declare namespace ExpectWebdriverIO {
|
|
10
11
|
const expect: ExpectWebdriverIO.Expect
|
|
11
12
|
function setOptions(options: DefaultOptions): void
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
14
|
function getConfig(): any
|
|
13
15
|
|
|
14
16
|
interface SnapshotServiceArgs {
|
|
@@ -23,32 +25,34 @@ declare namespace ExpectWebdriverIO {
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
interface SoftFailure {
|
|
26
|
-
error: Error
|
|
27
|
-
matcherName: string
|
|
28
|
-
location?: string
|
|
28
|
+
error: Error
|
|
29
|
+
matcherName: string
|
|
30
|
+
location?: string
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
class SoftAssertService {
|
|
32
|
-
static getInstance(): SoftAssertService
|
|
33
|
-
setCurrentTest(testId: string, testName?: string, testFile?: string): void
|
|
34
|
-
clearCurrentTest(): void
|
|
35
|
-
getCurrentTestId(): string | null
|
|
36
|
-
addFailure(error: Error, matcherName: string): void
|
|
37
|
-
getFailures(testId?: string): SoftFailure[]
|
|
38
|
-
clearFailures(testId?: string): void
|
|
39
|
-
assertNoFailures(testId?: string): void
|
|
34
|
+
static getInstance(): SoftAssertService
|
|
35
|
+
setCurrentTest(testId: string, testName?: string, testFile?: string): void
|
|
36
|
+
clearCurrentTest(): void
|
|
37
|
+
getCurrentTestId(): string | null
|
|
38
|
+
addFailure(error: Error, matcherName: string): void
|
|
39
|
+
getFailures(testId?: string): SoftFailure[]
|
|
40
|
+
clearFailures(testId?: string): void
|
|
41
|
+
assertNoFailures(testId?: string): void
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
interface SoftAssertionServiceOptions {
|
|
43
|
-
autoAssertOnTestEnd?: boolean
|
|
45
|
+
autoAssertOnTestEnd?: boolean
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
class SoftAssertionService implements ServiceInstance {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
constructor(serviceOptions?: SoftAssertionServiceOptions, capabilities?: any, config?: any)
|
|
51
|
+
beforeTest(test: Test): void
|
|
52
|
+
beforeStep(step: PickleStep, scenario: Scenario): void
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
afterTest(test: Test, context: any, result: TestResult): void
|
|
55
|
+
afterStep(step: PickleStep, scenario: Scenario, result: { passed: boolean, error?: Error }): void
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
interface AssertionResult {
|
|
@@ -59,7 +63,9 @@ declare namespace ExpectWebdriverIO {
|
|
|
59
63
|
const matchers: Map<
|
|
60
64
|
string,
|
|
61
65
|
(
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
67
|
actual: any,
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
69
|
...expected: any[]
|
|
64
70
|
) => Promise<AssertionResult>
|
|
65
71
|
>
|
|
@@ -79,6 +85,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
79
85
|
* expect(el).toHaveAttribute('attr', 'value', { ... }) // expectedValue is `['attr', 'value]`
|
|
80
86
|
* ```
|
|
81
87
|
*/
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
89
|
expectedValue?: any,
|
|
83
90
|
/**
|
|
84
91
|
* Options that the user has passed in, e.g. `expect(el).toHaveText('foo', { ignoreCase: true })` -> `{ ignoreCase: true }`
|
|
@@ -238,10 +245,10 @@ declare namespace ExpectWebdriverIO {
|
|
|
238
245
|
* **Usage**
|
|
239
246
|
* ```js
|
|
240
247
|
* // Check if an element has the class 'btn'
|
|
241
|
-
* await expect(element).toHaveElementClass('btn')
|
|
248
|
+
* await expect(element).toHaveElementClass('btn')
|
|
242
249
|
*
|
|
243
250
|
* // Check if an element has any of the specified classes
|
|
244
|
-
* await expect(element).toHaveElementClass(['btn', 'btn-large'])
|
|
251
|
+
* await expect(element).toHaveElementClass(['btn', 'btn-large'])
|
|
245
252
|
* ```
|
|
246
253
|
*/
|
|
247
254
|
toHaveElementClass(className: string | RegExp | Array<string | RegExp> | ExpectWebdriverIO.PartialMatcher, options?: ExpectWebdriverIO.StringOptions): R
|
|
@@ -251,6 +258,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
251
258
|
*/
|
|
252
259
|
toHaveElementProperty(
|
|
253
260
|
property: string | RegExp | ExpectWebdriverIO.PartialMatcher,
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
254
262
|
value?: any,
|
|
255
263
|
options?: ExpectWebdriverIO.StringOptions
|
|
256
264
|
): R
|
|
@@ -418,7 +426,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
418
426
|
toBeElementsArrayOfSize(
|
|
419
427
|
size: number | ExpectWebdriverIO.NumberOptions,
|
|
420
428
|
options?: ExpectWebdriverIO.NumberOptions
|
|
421
|
-
): R & Promise<WebdriverIO.ElementArray
|
|
429
|
+
): R & Promise<WebdriverIO.ElementArray>
|
|
422
430
|
|
|
423
431
|
// ==== network mock ====
|
|
424
432
|
/**
|
|
@@ -479,8 +487,10 @@ declare namespace ExpectWebdriverIO {
|
|
|
479
487
|
type JsonCompatible = jsonObject | jsonArray
|
|
480
488
|
|
|
481
489
|
interface PartialMatcher {
|
|
490
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
482
491
|
sample?: any
|
|
483
492
|
$$typeof: symbol
|
|
493
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
484
494
|
asymmetricMatch(...args: any[]): boolean
|
|
485
495
|
toString(): string
|
|
486
496
|
}
|
|
@@ -527,6 +537,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
527
537
|
}
|
|
528
538
|
|
|
529
539
|
interface AsymmetricMatchers {
|
|
540
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
530
541
|
any(expectedObject: any): PartialMatcher
|
|
531
542
|
anything(): PartialMatcher
|
|
532
543
|
arrayContaining(sample: Array<unknown>): PartialMatcher
|
package/types/standalone.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/consistent-type-imports*/
|
|
1
2
|
/// <reference types="./expect-webdriverio.js"/>
|
|
2
3
|
|
|
3
|
-
type ChainablePromiseElement = import('webdriverio').ChainablePromiseElement
|
|
4
|
-
type ChainablePromiseArray = import('webdriverio').ChainablePromiseArray
|
|
4
|
+
type ChainablePromiseElement = import('webdriverio').ChainablePromiseElement
|
|
5
|
+
type ChainablePromiseArray = import('webdriverio').ChainablePromiseArray
|
|
5
6
|
|
|
6
7
|
declare namespace ExpectWebdriverIO {
|
|
7
8
|
interface Matchers<R extends void | Promise<void>, T> extends Readonly<import('expect').Matchers<R>> {
|
|
@@ -21,6 +22,7 @@ declare namespace ExpectWebdriverIO {
|
|
|
21
22
|
} & AsymmetricMatchers
|
|
22
23
|
|
|
23
24
|
interface AsymmetricMatchers {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
26
|
any(expectedObject: any): PartialMatcher
|
|
25
27
|
anything(): PartialMatcher
|
|
26
28
|
arrayContaining(sample: Array<unknown>): PartialMatcher
|