Skip to content

Commit 0ab9888

Browse files
committed
Fix sync matcher that need to be async
1 parent 4e2deea commit 0ab9888

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

jasmine-wdio-expect-async.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ declare namespace ExpectWebdriverIO {
3232
// Should be the same as https://github.com/webdriverio/webdriverio/blob/ea0e3e00288abced4c739ff9e46c46977b7cdbd2/packages/wdio-jasmine-framework/src/index.ts#L21-L29
3333
interface JasmineAsymmetricMatchers extends Pick<ExpectWebdriverIO.AsymmetricMatchers, 'any' | 'anything' | 'arrayContaining' | 'objectContaining' | 'stringContaining' | 'stringMatching'> {}
3434

35-
// TODO dprevost review this!!!
35+
// Hack to convert all sync matchers to return Promise<void> since `wdio/jasmine-framework` forces `expect` to be async
3636
type JasmineSyncMatchers<T> = {
3737
[K in keyof jasmine.Matchers<T>]: K extends 'not'
3838
? JasmineSyncMatchers<T>
39+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3940
: jasmine.Matchers<T>[K] extends (...args: any) => any
41+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4042
? (...args: any[]) => Promise<void>
4143
: jasmine.Matchers<T>[K]
4244
}

test-types/jasmine/jasmine.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ describe('Jasmine type agumentations', () => {
354354
expectTypeOf(expectAsync('test').withContext('foo').toBeCustomJasmine()).toEqualTypeOf<Promise<void>>()
355355

356356
// Async Jasmine built-in matcher with context
357-
expectTypeOf(expectAsync(Promise.resolve(true)).withContext('foo').toBeResolved()).toEqualTypeOf<Promise<void>>()
357+
expectTypeOf(expectAsync(Promise.resolve(true)).withContext('foo').toBeResolved()).toEqualTypeOf<PromiseLike<void>>()
358358

359359
// Sync matcher with context
360360
expectTypeOf(expect(true).withContext('foo').toBe(true)).toEqualTypeOf<void>()

0 commit comments

Comments
 (0)