-
-
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.
expect-webdriverio: revert breaking change
- Loading branch information
1 parent
3a54956
commit 87a4b0a
Showing
3 changed files
with
60 additions
and
87 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,9 +1,3 @@ | ||
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,74 +1,64 @@ | ||
import { test, expect, vi } from 'vitest' | ||
import { matchers, expect as expectLib } from '../src/index.js' | ||
import { test, expect } from 'vitest' | ||
import Matchers from '../src/matchers.js' | ||
|
||
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', | ||
test('matchers', () => { | ||
expect(Object.keys(Matchers)).toEqual([ | ||
// browser | ||
'toHaveClipboardText', | ||
'toHaveClipboardTextContaining', | ||
'toHaveTitle', | ||
'toHaveTitleContaining', | ||
'toHaveUrl', | ||
'toHaveUrlContaining', | ||
|
||
// mock | ||
'toBeRequested', | ||
'toBeRequestedTimes', | ||
'toBeRequestedWith', | ||
'toBeRequestedWithResponse', | ||
// elements | ||
'toBeElementsArrayOfSize', | ||
|
||
// snapshot | ||
'toMatchSnapshot', | ||
'toMatchInlineSnapshot' | ||
] | ||
// 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', | ||
|
||
test('matchers', () => { | ||
expect([...matchers.keys()]).toEqual(ALL_MATCHERS) | ||
}) | ||
// mock | ||
'toBeRequested', | ||
'toBeRequestedTimes', | ||
'toBeRequestedWith', | ||
'toBeRequestedWithResponse', | ||
|
||
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') | ||
// snapshot | ||
'toMatchSnapshot', | ||
'toMatchInlineSnapshot' | ||
]) | ||
}) |