expect-webdriverio 4.7.1 → 4.8.0

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/lib/index.js CHANGED
@@ -1,8 +1,7 @@
1
- import { jestExpect as expectLib } from '@jest/expect';
1
+ import { expect as expectLib } from 'expect';
2
2
  import wdioMatchers from './matchers.js';
3
3
  import * as expectUtils from './utils.js';
4
4
  import { DEFAULT_OPTIONS } from './constants.js';
5
- expectLib.setState({ suppressedErrors: [] });
6
5
  expectLib.extend({ ...wdioMatchers });
7
6
  export const expect = expectLib;
8
7
  export const matchers = wdioMatchers;
package/lib/matchers.js CHANGED
@@ -16,7 +16,6 @@ import * as toHaveClass from './matchers/element/toHaveClass.js';
16
16
  import * as toHaveHref from './matchers/element/toHaveHref.js';
17
17
  import * as toHaveId from './matchers/element/toHaveId.js';
18
18
  import * as toHaveSize from './matchers/element/toHaveSize.js';
19
- import * as toMatchElementSnapshot from './matchers/element/toMatchElementSnapshot.js';
20
19
  import * as toHaveElementProperty from './matchers/element/toHaveElementProperty.js';
21
20
  import * as toHaveText from './matchers/element/toHaveText.js';
22
21
  import * as toHaveValue from './matchers/element/toHaveValue.js';
@@ -24,9 +23,7 @@ import * as toHaveStyle from './matchers/element/toHaveStyle.js';
24
23
  import * as toBeRequested from './matchers/mock/toBeRequested.js';
25
24
  import * as toBeRequestedTimes from './matchers/mock/toBeRequestedTimes.js';
26
25
  import * as toBeRequestedWith from './matchers/mock/toBeRequestedWith.js';
27
- import * as toMatchSnapshot from './matchers/general/toMatchSnapshot.js';
28
26
  const matchers = {
29
- ...toMatchSnapshot,
30
27
  ...toHaveClipboardText,
31
28
  ...toHaveTitle,
32
29
  ...toHaveUrl,
@@ -49,7 +46,6 @@ const matchers = {
49
46
  ...toHaveText,
50
47
  ...toHaveValue,
51
48
  ...toHaveStyle,
52
- ...toMatchElementSnapshot,
53
49
  ...toBeRequested,
54
50
  ...toBeRequestedTimes,
55
51
  ...toBeRequestedWith,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expect-webdriverio",
3
- "version": "4.7.1",
3
+ "version": "4.8.0",
4
4
  "author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
5
5
  "description": "WebdriverIO Assertion Library",
6
6
  "license": "MIT",
@@ -59,34 +59,32 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/debug": "^4.1.12",
62
- "@types/jest": "^29.5.8",
62
+ "@types/jest": "^29.5.11",
63
63
  "@types/lodash.isequal": "^4.5.8",
64
- "@types/node": "^20.9.2",
65
- "@typescript-eslint/eslint-plugin": "^6.11.0",
66
- "@typescript-eslint/parser": "^6.11.0",
67
- "@vitest/coverage-v8": "^0.34.6",
68
- "@wdio/globals": "^8.23.1",
69
- "c8": "^8.0.1",
70
- "eslint": "^8.54.0",
71
- "eslint-plugin-import": "^2.29.0",
72
- "eslint-plugin-unicorn": "^49.0.0",
64
+ "@types/node": "^20.10.6",
65
+ "@typescript-eslint/eslint-plugin": "^6.17.0",
66
+ "@typescript-eslint/parser": "^6.17.0",
67
+ "@vitest/coverage-v8": "^1.1.3",
68
+ "c8": "^9.0.0",
69
+ "eslint": "^8.56.0",
70
+ "eslint-plugin-import": "^2.29.1",
71
+ "eslint-plugin-unicorn": "^50.0.1",
73
72
  "husky": "^8.0.3",
74
73
  "npm-run-all": "^4.1.5",
75
- "release-it": "^17.0.0",
74
+ "release-it": "^17.0.1",
76
75
  "rimraf": "^5.0.5",
77
76
  "shelljs": "^0.8.5",
78
- "typescript": "^5.2.2",
79
- "vitest": "0.34.6",
80
- "webdriverio": "8.24.6"
77
+ "typescript": "^5.3.3",
78
+ "vitest": "1.1.3",
79
+ "webdriverio": "8.27.0"
81
80
  },
82
81
  "optionalDependencies": {
83
- "@wdio/globals": "^8.23.1",
84
- "@wdio/logger": "^8.16.17",
85
- "webdriverio": "^8.23.1"
82
+ "@wdio/globals": "^8.27.0",
83
+ "@wdio/logger": "^8.24.12",
84
+ "webdriverio": "^8.27.0"
86
85
  },
87
86
  "dependencies": {
88
- "jest-snapshot": "^29.7.0",
89
- "@jest/expect": "^29.7.0",
87
+ "expect": "^29.7.0",
90
88
  "jest-matcher-utils": "^29.7.0",
91
89
  "lodash.isequal": "^4.5.0"
92
90
  }
@@ -1,5 +1,7 @@
1
1
  declare namespace ExpectWebdriverIO {
2
- const expect: ExpectWebdriverIO.Expect
2
+ function expect<T = unknown, R extends void | Promise<void> = void | Promise<void>>(
3
+ actual: T
4
+ ): Matchers<R, T>
3
5
  function setOptions(options: DefaultOptions): void
4
6
  function getConfig(): any
5
7
 
@@ -20,7 +22,7 @@ declare namespace ExpectWebdriverIO {
20
22
  /**
21
23
  * name of the matcher, e.g. `toHaveText` or `toBeClickable`
22
24
  */
23
- matcherName: keyof Matchers<unknown, unknown>,
25
+ matcherName: keyof Matchers<void, unknown>,
24
26
  /**
25
27
  * Value that the user has passed in
26
28
  *
@@ -143,29 +145,6 @@ declare namespace ExpectWebdriverIO {
143
145
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
144
146
  interface Matchers<R, T> {
145
147
  // ===== $ or $$ =====
146
- /**
147
- * This ensures that element html value matches the most recent snapshot with property matchers.
148
- */
149
- toMatchElementSnapshot(hint?: string): R;
150
- /**
151
- * This ensures that element html matches the most recent snapshot.
152
- */
153
- toMatchElementSnapshot<U extends Record<keyof T, unknown>>(
154
- propertyMatchers: Partial<U>,
155
- hint?: string,
156
- ): R;
157
- /**
158
- * This ensures that element html matches the most recent snapshot with property matchers.
159
- */
160
- toMatchElementInlineSnapshot(snapshot?: string): R;
161
- /**
162
- * This ensures that element html matches the most recent snapshot with property matchers.
163
- */
164
- toMatchElementInlineSnapshot<U extends Record<keyof T, unknown>>(
165
- propertyMatchers: Partial<U>,
166
- snapshot?: string,
167
- ): R;
168
-
169
148
  /**
170
149
  * `WebdriverIO.Element` -> `isDisplayed`
171
150
  */
@@ -508,23 +487,23 @@ declare namespace ExpectWebdriverIO {
508
487
  method?: string | Array<string>
509
488
  statusCode?: number | Array<number>
510
489
  requestHeaders?:
511
- | Record<string, string>
512
- | ExpectWebdriverIO.PartialMatcher
513
- | ((headers: Record<string, string>) => boolean)
490
+ | Record<string, string>
491
+ | ExpectWebdriverIO.PartialMatcher
492
+ | ((headers: Record<string, string>) => boolean)
514
493
  responseHeaders?:
515
- | Record<string, string>
516
- | ExpectWebdriverIO.PartialMatcher
517
- | ((headers: Record<string, string>) => boolean)
494
+ | Record<string, string>
495
+ | ExpectWebdriverIO.PartialMatcher
496
+ | ((headers: Record<string, string>) => boolean)
518
497
  postData?:
519
- | string
520
- | ExpectWebdriverIO.JsonCompatible
521
- | ExpectWebdriverIO.PartialMatcher
522
- | ((r: string | undefined) => boolean)
498
+ | string
499
+ | ExpectWebdriverIO.JsonCompatible
500
+ | ExpectWebdriverIO.PartialMatcher
501
+ | ((r: string | undefined) => boolean)
523
502
  response?:
524
- | string
525
- | ExpectWebdriverIO.JsonCompatible
526
- | ExpectWebdriverIO.PartialMatcher
527
- | ((r: string) => boolean)
503
+ | string
504
+ | ExpectWebdriverIO.JsonCompatible
505
+ | ExpectWebdriverIO.PartialMatcher
506
+ | ((r: string) => boolean)
528
507
  }
529
508
 
530
509
  type jsonPrimitive = string | number | boolean | null
@@ -1,5 +1,8 @@
1
1
  /// <reference types="./standalone.js"/>
2
2
 
3
+ // @ts-expect-error
4
+ declare const expect: ExpectWebdriverIO.Expect
5
+
3
6
  declare namespace NodeJS {
4
7
  interface Global {
5
8
  expect: ExpectWebdriverIO.Expect;
@@ -4,18 +4,18 @@ type ChainablePromiseElement = import('webdriverio').ChainablePromiseElement<Web
4
4
  type ChainablePromiseArray = import('webdriverio').ChainablePromiseArray<WebdriverIO.Element>
5
5
 
6
6
  declare namespace ExpectWebdriverIO {
7
- interface Matchers<R extends void | Promise<void>, T> extends Readonly<import('expect').Matchers<R, T>>, Readonly<import('jest-snapshot').SnapshotMatchers<R, T>> {
7
+ interface Matchers<R extends void | Promise<void>, T> extends Readonly<import('expect').Matchers<R>> {
8
8
  not: Matchers<R, T>
9
9
  resolves: Matchers<R, T>
10
10
  rejects: Matchers<R, T>
11
11
  }
12
12
 
13
- type Expect = Readonly<import('@jest/expect').JestExpect> & {
13
+ type Expect = {
14
14
  <T = unknown, R extends void | Promise<void> = void | Promise<void>>(actual: T): Matchers<R, T>
15
15
  extend(map: Record<string, Function>): void
16
16
  } & AsymmetricMatchers
17
17
 
18
- type AsymmetricMatchers = {
18
+ interface AsymmetricMatchers {
19
19
  any(expectedObject: any): PartialMatcher
20
20
  anything(): PartialMatcher
21
21
  arrayContaining(sample: Array<unknown>): PartialMatcher
@@ -1,9 +0,0 @@
1
- import { toMatchSnapshot as jestToMatchSnapshot, toMatchInlineSnapshot as jestToMatchInlineSnapshot } from 'jest-snapshot';
2
- export async function toMatchElementSnapshot(el, ...args) {
3
- this.expectation = this.expectation || 'matchElementSnapshot';
4
- return jestToMatchSnapshot.call(this, await el.getHTML(), ...args);
5
- }
6
- export async function toMatchElementInlineSnapshot(el, ...args) {
7
- this.expectation = this.expectation || 'matchElementInlineSnapshot';
8
- return jestToMatchInlineSnapshot.call(this, await el.getHTML(), ...args);
9
- }
@@ -1,9 +0,0 @@
1
- import { toMatchSnapshot as jestToMatchSnapshot, toMatchInlineSnapshot as jestToMatchInlineSnapshot } from 'jest-snapshot';
2
- export async function toMatchSnapshot(received, ...args) {
3
- this.expectation = this.expectation || 'matchSnapshot';
4
- return jestToMatchSnapshot.call(this, await received, ...args);
5
- }
6
- export async function toMatchInlineSnapshot(received, ...args) {
7
- this.expectation = this.expectation || 'matchInlineSnapshot';
8
- return jestToMatchInlineSnapshot.call(this, await received, ...args);
9
- }