Skip to content

Commit c2955ab

Browse files
committed
add support for expect assertions
1 parent e18d6ae commit c2955ab

File tree

4 files changed

+207
-3
lines changed

4 files changed

+207
-3
lines changed

.github/workflows/release.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
name: release extension
9+
runs-on: macos-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@master
13+
- name: Setup Nodejs
14+
uses: actions/setup-node@master
15+
with:
16+
node-version: 16
17+
- name: Install dependencies
18+
run: npm install
19+
- name: release
20+
run: npm run publish -- -p ${{ secrets.ADPAT }}

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.3.0] - 01-08-2022 (DD-MM-YYYY)
2+
### Add support for expect assertions
3+
- toHaveUrl, toHaveUrlContaining, toHaveTitle, toHaveTitleContaining, toBeDisplayed, toExist, toBePresent, toBeExisting, toBeFocused, toHaveAttribute, toHaveAttr, toHaveAttributeContaining, toHaveAttrContaining, toHaveElementClass, toHaveElementClassContaining, toHaveElementProperty, toHaveValue, toHaveValueContaining, toBeClickable, toBeDisabled, toBeEnabled, toBeSelected, toBeChecked, toHaveHref, toHaveLink, toHaveHrefContaining, toHaveLinkContaining, toHaveId, toHaveText, toHaveTextContaining, toBeDisplayedInViewport, toHaveChildren, toBeElementsArrayOfSize, toBeRequested, toBeRequestedTimes, toBeRequestedWith
4+
15
## [0.2.0] - 05-12-2019 (DD-MM-YYYY)
26
### Add WebDriver Protocol Commands
37
- newSession

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vscode-webdriverio-snippets",
3-
"version": "0.2.0",
4-
"description": "WebDriverIO code snippets for Visual Studio Code",
3+
"version": "0.3.0",
4+
"description": "WebDriverIO snippets for Visual Studio Code",
55
"displayName": "WebDriverIO snippets",
66
"publisher": "Raju",
77
"keywords": [
@@ -44,6 +44,6 @@
4444
]
4545
},
4646
"devDependencies": {
47-
"vsce": "^1.100.2"
47+
"vsce": "^2.10.0"
4848
}
4949
}

snippets/webdriverio_snippets.json

+180
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,184 @@
11
{
2+
"toHaveUrl": {
3+
"prefix": "wdtoHaveUrl",
4+
"body": "expect(browser).toHaveUrl(${1:expectedUrl})",
5+
"description": "Checks if browser is on a specific page"
6+
},
7+
"toHaveUrlContaining": {
8+
"prefix": "wdtoHaveUrlContaining",
9+
"body": "expect(browser).toHaveUrlContaining(${1:expectedValue})",
10+
"description": "Checks if browser is on a page URL that contains a value"
11+
},
12+
"toHaveTitle": {
13+
"prefix": "wdtoHaveTitle",
14+
"body": "expect(browser).toHaveTitle(${1:expectedTitle})",
15+
"description": "Checks if website has a specific title"
16+
},
17+
"toHaveTitleContaining": {
18+
"prefix": "wdtoHaveTitleContaining",
19+
"body": "expect(browser).toHaveTitleContaining(${1:expectedValue})",
20+
"description": "Checks if website has a specific title that contains a value"
21+
},
22+
"toBeDisplayed": {
23+
"prefix": "wdtoBeDisplayed",
24+
"body": "expect(${1:element}).toBeDisplayed()",
25+
"description": "Calls isDisplayed on given element"
26+
},
27+
"toExist": {
28+
"prefix": "wdtoExist",
29+
"body": "expect(${1:element}).toExist()",
30+
"description": "Calls isExisting on given element"
31+
},
32+
"toBePresent": {
33+
"prefix": "wdtoBePresent",
34+
"body": "expect(${1:element}).toBePresent()",
35+
"description": "Same as toExist"
36+
},
37+
"toBeExisting": {
38+
"prefix": "wdtoBeExisting",
39+
"body": "expect(${1:element}).toBeExisting()",
40+
"description": "Same as toExist"
41+
},
42+
"toBeFocused": {
43+
"prefix": "wdtoBeFocused",
44+
"body": "expect(${1:element}).toBeFocused()",
45+
"description": "Checks if element has focus. This assertion only works in a web context"
46+
},
47+
"toHaveAttribute": {
48+
"prefix": "wdtoHaveAttribute",
49+
"body": "expect(${1:element}).toHaveAttribute(${2:attribute}, ${3:expectedValue})",
50+
"description": "Checks if an element has a certain attribute with a specific value"
51+
},
52+
"toHaveAttr": {
53+
"prefix": "wdtoHaveAttr",
54+
"body": "expect(${1:element}).toHaveAttr(${2:attribute}, ${3:expectedValue})",
55+
"description": "Same as toHaveAttribute"
56+
},
57+
"toHaveAttributeContaining": {
58+
"prefix": "wdtoHaveAttributeContaining",
59+
"body": "expect(${1:element}).toHaveAttributeContaining(${2:attribute}, ${3:expectedValue})",
60+
"description": "Checks if an element has a certain attribute that contains a value"
61+
},
62+
"toHaveAttrContaining": {
63+
"prefix": "wdtoHaveAttrContaining",
64+
"body": "expect(${1:element}).toHaveAttrContaining(${2:attribute}, ${3:expectedValue})",
65+
"description": "Same as toHaveAttributeContaining"
66+
},
67+
"toHaveElementClass": {
68+
"prefix": "wdtoHaveElementClass",
69+
"body": "expect(${1:element}).toHaveElementClass(${2:className}, { message: ${3:textOnError}, })",
70+
"description": "Checks if an element has a certain class name"
71+
},
72+
"toHaveElementClassContaining": {
73+
"prefix": "wdtoHaveElementClassContaining",
74+
"body": "expect(${1:element}).toHaveElementClassContaining(${2:expectedValue})",
75+
"description": "Checks if an element has a certain class name that contains provided value"
76+
},
77+
"toHaveElementProperty": {
78+
"prefix": "wdtoHaveElementProperty",
79+
"body": "expect(${1:element}).toHaveElementProperty(${2:property}, ${3:expectedValue})",
80+
"description": "Checks if an element has a certain property"
81+
},
82+
"toHaveValue": {
83+
"prefix": "wdtoHaveValue",
84+
"body": "expect(${1:element}).toHaveValue(${2:expectedValue}, { ignoreCase: ${3:true} })",
85+
"description": "Checks if an input element has a certain value"
86+
},
87+
"toHaveValueContaining": {
88+
"prefix": "wdtoHaveValueContaining",
89+
"body": "expect(${1:element}).toHaveValueContaining(${2:expectedValue})",
90+
"description": "Checks if an input element contains a certain value"
91+
},
92+
"toBeClickable": {
93+
"prefix": "wdtoBeClickable",
94+
"body": "expect(${1:element}).toBeClickable()",
95+
"description": "Checks if an element can be clicked by calling isClickable on the element"
96+
},
97+
"toBeDisabled": {
98+
"prefix": "wdtoBeDisabled",
99+
"body": "expect(${1:element}).toBeDisabled()",
100+
"description": "Checks if an element is disabled by calling isEnabled on the element"
101+
},
102+
"toBeEnabled": {
103+
"prefix": "wdtoBeEnabled",
104+
"body": "expect(${1:element}).toBeEnabled()",
105+
"description": "Checks if an element is enabled by calling isEnabled on the element"
106+
},
107+
"toBeSelected": {
108+
"prefix": "wdtoBeSelected",
109+
"body": "expect(${1:element}).toBeSelected()",
110+
"description": "Checks if an element is enabled by calling isSelected on the element"
111+
},
112+
"toBeChecked": {
113+
"prefix": "wdtoBeChecked",
114+
"body": "expect(${1:element}).toBeChecked()",
115+
"description": "Same as toBeSelected"
116+
},
117+
"toHaveHref": {
118+
"prefix": "wdtoHaveHref",
119+
"body": "expect(${1:element}).toHaveHref(${2:expectedValue})",
120+
"description": "Checks if link element has a specific link target"
121+
},
122+
"toHaveLink": {
123+
"prefix": "wdtoHaveLink",
124+
"body": "expect(${1:element}).toHaveLink(${2:expectedValue})",
125+
"description": "Same as toHaveHref"
126+
},
127+
"toHaveHrefContaining": {
128+
"prefix": "wdtoHaveHrefContaining",
129+
"body": "expect(${1:element}).toHaveHrefContaining(${2:expectedValue})",
130+
"description": "Checks if link element contains a specific link target"
131+
},
132+
"toHaveLinkContaining": {
133+
"prefix": "wdtoHaveLinkContaining",
134+
"body": "expect(${1:element}).toHaveLinkContaining(${2:expectedValue})",
135+
"description": "Same as toHaveHrefContaining"
136+
},
137+
"toHaveId": {
138+
"prefix": "wdtoHaveId",
139+
"body": "expect(${1:element}).toHaveId(${2:expectedId})",
140+
"description": "Checks if element has a specific id attribute"
141+
},
142+
"toHaveText": {
143+
"prefix": "wdtoHaveText",
144+
"body": "expect(${1:element}).toHaveText(${2:expectedText})",
145+
"description": "Checks if element has a specific text. Can also be called with an array as parameter in the case where the element can have different texts"
146+
},
147+
"toHaveTextContaining": {
148+
"prefix": "wdtoHaveTextContaining",
149+
"body": "expect(${1:element}).toHaveTextContaining(${2:expectedText})",
150+
"description": "Checks if element contains a specific text. Can also be called with an array as parameter in the case where the element can have different texts"
151+
},
152+
"toBeDisplayedInViewport": {
153+
"prefix": "wdtoBeDisplayedInViewport",
154+
"body": "expect(${1:element}).toBeDisplayedInViewport()",
155+
"description": "Checks if an element is within the viewport by calling isDisplayedInViewport on the element"
156+
},
157+
"toHaveChildren": {
158+
"prefix": "wdtoHaveChildren",
159+
"body": "expect(${1:element}).toHaveChildren(${2:optionalExpectedCount})",
160+
"description": "Checks amount of the fetched element's children by calling element.$('./*') command"
161+
},
162+
"toBeElementsArrayOfSize": {
163+
"prefix": "wdtoBeElementsArrayOfSize",
164+
"body": "expect(${1:listItems}).toBeElementsArrayOfSize(${2:expectedCount})",
165+
"description": "Checks amount of fetched elements using $$ command"
166+
},
167+
"toBeRequested": {
168+
"prefix": "wdtoBeRequested",
169+
"body": "expect(${1:mock}).toBeRequested()",
170+
"description": "Checks that mock was called"
171+
},
172+
"toBeRequestedTimes": {
173+
"prefix": "wdtoBeRequestedTimes",
174+
"body": "expect(${1:mock}).toBeRequestedTimes(${2:expectedCount})",
175+
"description": "Checks that mock was called for the expected amount of times"
176+
},
177+
"toBeRequestedWith": {
178+
"prefix": "wdtoBeRequestedWith",
179+
"body": "expect(${1:mock}).toBeRequestedWith({ ${2:expectedOptions} })",
180+
"description": "Checks that mock was called according to the expected options"
181+
},
2182
"newSession": {
3183
"prefix": "wdnewSession",
4184
"body": "browser.newSession(${1:capabilities})",

0 commit comments

Comments
 (0)