-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "expect-webdriverio: revert breaking change"
This reverts commit 87a4b0a.
- Loading branch information
1 parent
1315a55
commit 28c2ed7
Showing
3 changed files
with
87 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import type { ExpectationResult, MatcherContext } from 'expect' | ||
|
||
export type WdioElementMaybePromise = | ||
WebdriverIO.Element | WebdriverIO.ElementArray | | ||
Promise<WebdriverIO.Element> | Promise<WebdriverIO.ElementArray> | ||
|
||
export type RawMatcherFn<Context extends MatcherContext = MatcherContext> = { | ||
(this: Context, actual: any, ...expected: Array<any>): ExpectationResult; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,74 @@ | ||
import { test, expect } from 'vitest' | ||
import Matchers from '../src/matchers.js' | ||
import { test, expect, vi } from 'vitest' | ||
import { matchers, expect as expectLib } from '../src/index.js' | ||
|
||
test('matchers', () => { | ||
expect(Object.keys(Matchers)).toEqual([ | ||
// browser | ||
'toHaveClipboardText', | ||
'toHaveClipboardTextContaining', | ||
'toHaveTitle', | ||
'toHaveTitleContaining', | ||
'toHaveUrl', | ||
'toHaveUrlContaining', | ||
const ALL_MATCHERS = [ | ||
// browser | ||
'toHaveClipboardText', | ||
'toHaveClipboardTextContaining', | ||
'toHaveTitle', | ||
'toHaveTitleContaining', | ||
'toHaveUrl', | ||
'toHaveUrlContaining', | ||
|
||
// elements | ||
'toBeElementsArrayOfSize', | ||
|
||
// elements | ||
'toBeClickable', | ||
'toBeDisabled', | ||
'toBeDisplayed', | ||
'toBeDisplayedInViewport', | ||
'toBeEnabled', | ||
'toExist', | ||
'toBeExisting', | ||
'toBePresent', | ||
'toBeFocused', | ||
'toBeSelected', | ||
'toBeChecked', | ||
'toHaveAttributeAndValue', | ||
'toHaveAttribute', | ||
'toHaveAttributeContaining', | ||
'toHaveAttrContaining', | ||
'toHaveAttr', | ||
'toHaveChildren', | ||
'toHaveClass', | ||
'toHaveElementClass', | ||
'toHaveElementClassContaining', | ||
'toHaveClassContaining', | ||
'toHaveHref', | ||
'toHaveLink', | ||
'toHaveHrefContaining', | ||
'toHaveLinkContaining', | ||
'toHaveHTML', | ||
'toHaveHTMLContaining', | ||
'toHaveId', | ||
'toHaveSize', | ||
'toHaveElementProperty', | ||
'toHaveText', | ||
'toHaveTextContaining', | ||
'toHaveValue', | ||
'toHaveValueContaining', | ||
'toHaveStyle', | ||
|
||
// elements | ||
'toBeElementsArrayOfSize', | ||
// mock | ||
'toBeRequested', | ||
'toBeRequestedTimes', | ||
'toBeRequestedWith', | ||
'toBeRequestedWithResponse', | ||
|
||
// elements | ||
'toBeClickable', | ||
'toBeDisabled', | ||
'toBeDisplayed', | ||
'toBeDisplayedInViewport', | ||
'toBeEnabled', | ||
'toExist', | ||
'toBeExisting', | ||
'toBePresent', | ||
'toBeFocused', | ||
'toBeSelected', | ||
'toBeChecked', | ||
'toHaveAttributeAndValue', | ||
'toHaveAttribute', | ||
'toHaveAttributeContaining', | ||
'toHaveAttrContaining', | ||
'toHaveAttr', | ||
'toHaveChildren', | ||
'toHaveClass', | ||
'toHaveElementClass', | ||
'toHaveElementClassContaining', | ||
'toHaveClassContaining', | ||
'toHaveHref', | ||
'toHaveLink', | ||
'toHaveHrefContaining', | ||
'toHaveLinkContaining', | ||
'toHaveHTML', | ||
'toHaveHTMLContaining', | ||
'toHaveId', | ||
'toHaveSize', | ||
'toHaveElementProperty', | ||
'toHaveText', | ||
'toHaveTextContaining', | ||
'toHaveValue', | ||
'toHaveValueContaining', | ||
'toHaveStyle', | ||
// snapshot | ||
'toMatchSnapshot', | ||
'toMatchInlineSnapshot' | ||
] | ||
|
||
// mock | ||
'toBeRequested', | ||
'toBeRequestedTimes', | ||
'toBeRequestedWith', | ||
'toBeRequestedWithResponse', | ||
test('matchers', () => { | ||
expect([...matchers.keys()]).toEqual(ALL_MATCHERS) | ||
}) | ||
|
||
// snapshot | ||
'toMatchSnapshot', | ||
'toMatchInlineSnapshot' | ||
]) | ||
test('allows to add matcher', () => { | ||
const matcher: any = vi.fn((actual: any, expected: any) => ({ pass: actual === expected })) | ||
expectLib.extend({ toBeCustom: matcher }) | ||
// @ts-expect-error not in types | ||
expectLib('foo').toBeCustom('foo') | ||
expect(matchers.keys()).toContain('toBeCustom') | ||
}) |