Skip to content

Commit 5e829e9

Browse files
committed
Use built-in PromiseLike
1 parent 0d76525 commit 5e829e9

6 files changed

Lines changed: 23 additions & 25 deletions

File tree

jest.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ declare namespace jest {
4646
* Soft assertions record failures but don't throw errors immediately
4747
* All failures are collected and reported at the end of the test
4848
*/
49-
soft<T = unknown>(actual: T): T extends PromiseLikeType ? MatcherAndInverse<Promise<void>, T> : MatcherAndInverse<void, T>
49+
soft<T = unknown>(actual: T): T extends PromiseLike<unknown> ? MatcherAndInverse<Promise<void>, T> : MatcherAndInverse<void, T>
5050

5151
/**
5252
* Get all current soft assertion failures

test/snapshot.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ test('supports cucumber snapshot testing', async () => {
7272
const expectedSnapfileExist = await fs.access(path.resolve(__dirname, 'file.feature.snap'))
7373
.then(() => true, () => false)
7474
expect(expectedSnapfileExist).toBe(true)
75-
})
75+
})

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
},
2020
"include": [
2121
"./test/**/*.ts",
22-
"./src/**/*.ts",
22+
"./src/**/*.ts"
2323
]
2424
}

types/expect-webdriverio.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ type ChainablePromiseElement = import('webdriverio').ChainablePromiseElement
1111
type ChainablePromiseArray = import('webdriverio').ChainablePromiseArray
1212
type ExpectLibAsymmetricMatcher<T> = import('expect').AsymmetricMatcher<T>
1313

14-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
15-
type PromiseLikeType = Promise<any>
1614
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T
1715

1816
interface WdioBrowserMatchers<R, T = unknown>{
@@ -364,7 +362,7 @@ interface WdioCustomExpect extends WdioAsymmetricMatchers {
364362
* Soft assertions record failures but don't throw errors immediately
365363
* All failures are collected and reported at the end of the test
366364
*/
367-
soft<T = unknown>(actual: T): T extends PromiseLikeType ? Matchers<Promise<void>, T> : Matchers<void, T>
365+
soft<T = unknown>(actual: T): T extends PromiseLike ? Matchers<Promise<void>, T> : Matchers<void, T>
368366

369367
/**
370368
* Get all current soft assertion failures

types/jasmine-soft-extend.d.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ declare global {
1818
* All failures are collected and reported at the end of the test
1919
*/
2020
function soft<T>(actual: T): jasmine.Matchers<T>
21-
// soft<T = unknown>(actual: T): T extends PromiseLikeType ? Matchers<Promise<void>, T> : Matchers<void, T>
21+
// soft<T = unknown>(actual: T): T extends PromiseLike ? Matchers<Promise<void>, T> : Matchers<void, T>
2222

2323
/**
2424
* Get all current soft assertion failures
@@ -36,14 +36,14 @@ declare global {
3636
function clearSoftFailures(testId?: string): void
3737

3838
/** Expect Asymmetric Matchers */
39-
function any(sample: unknown): AsyncMatcher
40-
function anything(): AsyncMatcher
41-
function arrayContaining(sample: Array<unknown>): AsyncMatcher
42-
function arrayOf(sample: unknown): AsyncMatcher
43-
function closeTo(sample: number, precision?: number): AsyncMatcher
44-
function objectContaining(sample: Record<string, unknown>): AsyncMatcher
45-
function stringContaining(sample: string): AsyncMatcher
46-
function stringMatching(sample: string | RegExp): AsyncMatcher
39+
// function any(sample: unknown): AsyncMatcher
40+
// function anything(): AsyncMatcher
41+
// function arrayContaining(sample: Array<unknown>): AsyncMatcher
42+
// function arrayOf(sample: unknown): AsyncMatcher
43+
// function closeTo(sample: number, precision?: number): AsyncMatcher
44+
// function objectContaining(sample: Record<string, unknown>): AsyncMatcher
45+
// function stringContaining(sample: string): AsyncMatcher
46+
// function stringMatching(sample: string | RegExp): AsyncMatcher
4747
}
4848

4949
namespace expectAsync {
@@ -56,7 +56,7 @@ declare global {
5656
* All failures are collected and reported at the end of the test
5757
*/
5858
function soft<T>(actual: T): jasmine.Matchers<T>
59-
// soft<T = unknown>(actual: T): T extends PromiseLikeType ? Matchers<Promise<void>, T> : Matchers<void, T>
59+
// soft<T = unknown>(actual: T): T extends PromiseLike ? Matchers<Promise<void>, T> : Matchers<void, T>
6060

6161
/**
6262
* Get all current soft assertion failures
@@ -74,14 +74,14 @@ declare global {
7474
function clearSoftFailures(testId?: string): void
7575

7676
/** Expect Asymmetric Matchers */
77-
function any(sample: unknown): AsyncMatcher
78-
function anything(): AsyncMatcher
79-
function arrayContaining(sample: Array<unknown>): AsyncMatcher
80-
function arrayOf(sample: unknown): AsyncMatcher
81-
function closeTo(sample: number, precision?: number): AsyncMatcher
82-
function objectContaining(sample: Record<string, unknown>): AsyncMatcher
83-
function stringContaining(sample: string): AsyncMatcher
84-
function stringMatching(sample: string | RegExp): AsyncMatcher
77+
// function any(sample: unknown): AsyncMatcher
78+
// function anything(): AsyncMatcher
79+
// function arrayContaining(sample: Array<unknown>): AsyncMatcher
80+
// function arrayOf(sample: unknown): AsyncMatcher
81+
// function closeTo(sample: number, precision?: number): AsyncMatcher
82+
// function objectContaining(sample: Record<string, unknown>): AsyncMatcher
83+
// function stringContaining(sample: string): AsyncMatcher
84+
// function stringMatching(sample: string | RegExp): AsyncMatcher
8585
}
8686
}
8787

types/standalone.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ declare namespace ExpectWebdriverIO {
5151
* Soft assertions record failures but don't throw errors immediately
5252
* All failures are collected and reported at the end of the test
5353
*/
54-
soft<T = unknown>(actual: T): T extends PromiseLikeType ? MatchersAndInverse<Promise<void>, T> : MatchersAndInverse<void, T>
54+
soft<T = unknown>(actual: T): T extends PromiseLike<unknown> ? MatchersAndInverse<Promise<void>, T> : MatchersAndInverse<void, T>
5555

5656
/**
5757
* Get all current soft assertion failures

0 commit comments

Comments
 (0)