Skip to content

Commit 99530f5

Browse files
committed
Use MatchersObject from Jest's expect lib
1 parent db6c6d7 commit 99530f5

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="../types/expect-webdriverio.d.ts" />
22
import { expect as expectLib } from 'expect'
3-
import type { WdioMatchersObject, RawMatcherFn } from './types.js'
3+
import type { RawMatcherFn } from './types.js'
44
import * as wdioMatchers from './matchers.js'
55
import { DEFAULT_OPTIONS, defaultOptionsList } from './constants.js'
66
import createSoftExpect from './softExpect.js'
@@ -9,14 +9,14 @@ import { SoftAssertService } from './softAssert.js'
99
/**
1010
* Contains only the custom WDIO matchers to be used with `expect.extend()`.
1111
*/
12-
export const wdioCustomMatchers: WdioMatchersObject = {}
12+
export const wdioCustomMatchers: MatchersObject = {}
1313

1414
/**
1515
* @deprecated use `wdioCustomMatchers` instead
1616
*/
1717
export const matchers = new Map<string, RawMatcherFn>()
1818

19-
const filteredMatchers: WdioMatchersObject = {}
19+
const filteredMatchers: MatchersObject = {}
2020
const extend = expectLib.extend
2121

2222
// filter out matchers that aren't a function
@@ -38,9 +38,7 @@ expectLib.extend = (m) => {
3838
return extend(m)
3939
}
4040

41-
type MatchersObject = Parameters<typeof expectLib.extend>[0]
42-
43-
expectLib.extend(filteredMatchers as MatchersObject)
41+
expectLib.extend(filteredMatchers)
4442

4543
// Extend the expect object with soft assertions
4644
const expectWithSoft = expectLib as unknown as ExpectWebdriverIO.Expect

src/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ export type WdioElementsMaybePromise =
1414
export type RawMatcherFn<Context extends MatcherContext = MatcherContext> = {
1515
(this: Context, actual: unknown, ...expected: unknown[]): ExpectationResult;
1616
}
17-
18-
export type WdioMatchersObject = Record<string, RawMatcherFn>

types/expect-webdriverio.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type ExpectLibSyncExpectationResult = import('expect').SyncExpectationResult
2020
type ExpectLibAsyncExpectationResult = import('expect').AsyncExpectationResult
2121
type ExpectLibExpectationResult = import('expect').ExpectationResult
2222
type ExpectLibMatcherContext = import('expect').MatcherContext
23-
type MatchersObject = import('expect').MatchersObject
23+
type MatchersObject = Parameters<typeof import('expect').expect.extend>[0]
2424

2525
// Extracted from the expect library, this is the type of the matcher function used in the expect library.
2626
type RawMatcherFn<Context extends ExpectLibMatcherContext = ExpectLibMatcherContext> = {

0 commit comments

Comments
 (0)