@quickpickle/vitest-browser 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,35 +33,35 @@ expect.extend({
33
33
 
34
34
  Then('I should see {string}( on the page)', async function (world:VitestBrowserWorld, text) {
35
35
  await world.expectText(world.page, text)
36
- })
36
+ }, -10)
37
37
  Then('I should not/NOT see {string}( on the page)', async function (world:VitestBrowserWorld, text) {
38
38
  await world.expectText(world.page, text, false)
39
- })
39
+ }, -10)
40
40
  Then('the text {string} should be visible( on the page)', async function (world:VitestBrowserWorld, text) {
41
41
  await world.expectText(world.page, text)
42
- })
42
+ }, -10)
43
43
  Then('the text {string} should not/NOT be visible( on the page)', async function (world:VitestBrowserWorld, text) {
44
44
  await world.expectText(world.page, text, false)
45
- })
45
+ }, -10)
46
46
 
47
47
  // ================
48
48
  // Elements on page
49
49
  Then('I should see a/an/the {string} {word}', async function (world:VitestBrowserWorld, identifier, role) {
50
50
  let locator = await world.getLocator(world.page, identifier, role)
51
51
  await world.expectElement(locator)
52
- })
52
+ }, -10)
53
53
  Then('I should not/NOT see a/an/the {string} {word}', async function (world:VitestBrowserWorld, identifier, role) {
54
54
  let locator = await world.getLocator(world.page, identifier, role)
55
55
  await world.expectElement(locator, false)
56
- })
56
+ }, -10)
57
57
  Then('I should see a/an/the {string} (element )with (the )(text ){string}', async function (world:VitestBrowserWorld, identifier, text) {
58
58
  let locator = await world.getLocator(world.page, identifier, 'element', text)
59
59
  await world.expectElement(locator)
60
- })
60
+ }, -10)
61
61
  Then('I should not/NOT see a/an/the {string} (element )with (the )(text ){string}', async function (world:VitestBrowserWorld, identifier, text) {
62
62
  let locator = await world.getLocator(world.page, identifier, 'element', text)
63
63
  await world.expectElement(locator, false)
64
- })
64
+ }, -10)
65
65
 
66
66
  // ================
67
67
  // Actions
@@ -69,14 +69,14 @@ Then('{string} should have been clicked/doubleclicked/dblclicked', async functio
69
69
  let single = world.info.step?.match(/ clicked$/)
70
70
  if (single) expect(world.actions.clicks.find((el) => (el && el?.textContent === text))).not.toBeNull()
71
71
  else expect(world.actions.doubleClicks.find((el) => (el && el?.textContent === text))).not.toBeNull()
72
- })
72
+ }, -10)
73
73
 
74
74
  Then('(the ){string} {word} should have been clicked/doubleclicked/dblclicked', async function (world:VitestBrowserWorld, identifier, role) {
75
75
  let single = world.info.step?.match(/ clicked$/)
76
76
  let element = world.getLocator(world.page, identifier, role)
77
77
  if (single) expect(world.actions.clicks.find((el) => (el === element))).not.toBeNull()
78
78
  else expect(world.actions.doubleClicks.find((el) => (el === element))).not.toBeNull()
79
- })
79
+ }, -10)
80
80
 
81
81
  // ================
82
82
  // Element state
@@ -84,95 +84,95 @@ Then('a/an/the {string} {word} should be visible/hidden/invisible', async functi
84
84
  let state = world.info.step?.match(/(\w+)$/)![0]
85
85
  let locator = world.getLocator(world.page, identifier, role)
86
86
  await world.expectElement(locator, true, state === 'visible')
87
- })
87
+ }, -10)
88
88
  Then('a/an/the {string} (element )with (the )(text ){string} should be visible/hidden/invisible', async function (world:VitestBrowserWorld, identifier, text) {
89
89
  let state = world.info.step?.match(/(\w+)$/)![0]
90
90
  let locator = world.getLocator(world.page, identifier, 'element', text)
91
91
  await world.expectElement(locator, true, state === 'visible')
92
- })
92
+ }, -10)
93
93
  // Then('a/an/the {string} {word} should be attached/detatched', async function (world:VitestBrowserWorld, identifier, role) {
94
94
  // let state = world.info.step?.match(/(\w)$/)![0] as 'attached'|'detached'
95
95
  // let locator = world.getLocator(world.page, identifier, role)
96
- // await locator.waitFor({ state, timeout:world.worldConfig.stepTimeout })
97
- // })
96
+ // await locator.waitFor({ state })
97
+ // }, -10)
98
98
  // Then('a/an/the {string} (element )with (the )(text ){string} should be attached/detatched', async function (world:VitestBrowserWorld, identifier, text) {
99
99
  // let state = world.info.step?.match(/(\w)$/)![0] as 'attached'|'detached'
100
100
  // let locator = world.getLocator(world.page, identifier, 'element', text)
101
- // await locator.waitFor({ state, timeout:world.worldConfig.stepTimeout })
102
- // })
101
+ // await locator.waitFor({ state })
102
+ // }, -10)
103
103
 
104
104
  // disabled / enabled
105
105
  Then('a/an/the {string} {word} should be disabled', async function (world:VitestBrowserWorld, identifier, role) {
106
106
  let locator = await world.getLocator(world.page, identifier, role)
107
107
  await expect(locator).toBeDisabled()
108
- })
108
+ }, -10)
109
109
  Then('a/an/the {string} {word} should be enabled', async function (world:VitestBrowserWorld, identifier, role) {
110
110
  let locator = await world.getLocator(world.page, identifier, role)
111
111
  await expect(locator).toBeEnabled()
112
- })
112
+ }, -10)
113
113
  Then('a/an/the {string} (element )with (the )(text ){string} should be disabled', async function (world:VitestBrowserWorld, identifier, text) {
114
114
  let locator = await world.getLocator(world.page, identifier, 'element', text)
115
115
  await expect(locator).toBeDisabled()
116
- })
116
+ }, -10)
117
117
  Then('a/an/the {string} (element )with (the )(text ){string} should be enabled', async function (world:VitestBrowserWorld, identifier, text) {
118
118
  let locator = await world.getLocator(world.page, identifier, 'element', text)
119
119
  await expect(locator).toBeEnabled()
120
- })
120
+ }, -10)
121
121
 
122
122
  // checked / unchecked
123
123
  Then('a/an/the {string} {word} should be checked', async function (world:VitestBrowserWorld, identifier, role) {
124
124
  let locator = await world.getLocator(world.page, identifier, role)
125
125
  await expect(locator).toBeChecked()
126
- })
126
+ }, -10)
127
127
  Then('a/an/the {string} {word} should be unchecked', async function (world:VitestBrowserWorld, identifier, role) {
128
128
  let locator = await world.getLocator(world.page, identifier, role)
129
129
  await expect(locator).not.toBeChecked()
130
- })
130
+ }, -10)
131
131
  Then('a/an/the {string} (element )with (the )(text ){string} should be checked', async function (world:VitestBrowserWorld, identifier, text) {
132
132
  let locator = await world.getLocator(world.page, identifier, 'element', text)
133
133
  await expect(locator).toBeChecked()
134
- })
134
+ }, -10)
135
135
  Then('a/an/the {string} (element )with (the )(text ){string} should be unchecked', async function (world:VitestBrowserWorld, identifier, text) {
136
136
  let locator = await world.getLocator(world.page, identifier, 'element', text)
137
137
  await expect(locator).not.toBeChecked()
138
- })
138
+ }, -10)
139
139
 
140
140
  // focused / unfocused
141
141
  Then('a/an/the {string} {word} should be focused/active', async function (world:VitestBrowserWorld, identifier, role) {
142
142
  let locator = await world.getLocator(world.page, identifier, role)
143
143
  await expect(locator).toHaveFocus()
144
- })
144
+ }, -10)
145
145
  Then('a/an/the {string} {word} should be unfocused/blurred', async function (world:VitestBrowserWorld, identifier, role) {
146
146
  let locator = await world.getLocator(world.page, identifier, role)
147
147
  await expect(locator).not.toHaveFocus()
148
- })
148
+ }, -10)
149
149
  Then('a/an/the {string} (element )with (the )(text ){string} should be focused/active', async function (world:VitestBrowserWorld, identifier, text) {
150
150
  let locator = await world.getLocator(world.page, identifier, 'element', text)
151
151
  await expect(locator).toHaveFocus()
152
- })
152
+ }, -10)
153
153
  Then('a/an/the {string} (element )with (the )(text ){string} should be unfocused/blurred', async function (world:VitestBrowserWorld, identifier, text) {
154
154
  let locator = await world.getLocator(world.page, identifier, 'element', text)
155
155
  await expect(locator).not.toHaveFocus()
156
- })
156
+ }, -10)
157
157
 
158
158
  Then('a/an/the {string} {word} should be in(side) (of )the viewport', async function (world:VitestBrowserWorld, identifier, role) {
159
159
  let locator = await world.getLocator(world.page, identifier, role)
160
160
  // @ts-ignore
161
161
  await expect(locator).toBeInTheViewport()
162
- })
162
+ }, -10)
163
163
  Then('a/an/the {string} {word} should be out(side) (of )the viewport', async function (world:VitestBrowserWorld, identifier, role) {
164
164
  let locator = await world.getLocator(world.page, identifier, role)
165
165
  // @ts-ignore
166
166
  expect(locator).not.toBeInTheViewport()
167
- })
167
+ }, -10)
168
168
  // Then('a/an/the {string} (element )with (the )(text ){string} should be in(side) (of )the viewport', async function (world:VitestBrowserWorld, identifier, text) {
169
169
  // let locator = await world.getLocator(world.page, identifier, 'element', text)
170
170
  // await isInViewport(world, locator)
171
- // })
171
+ // }, -10)
172
172
  // Then('a/an/the {string} (element )with (the )(text ){string} should be out(side) (of )the viewport', async function (world:VitestBrowserWorld, identifier, text) {
173
173
  // let locator = await world.getLocator(world.page, identifier, 'element', text)
174
174
  // await isInViewport(world, locator)
175
- // })
175
+ // }, -10)
176
176
 
177
177
  // Values
178
178
  Then('a/an/the (value of ){string} should contain/include/be/equal {string}', async function (world:VitestBrowserWorld, identifier, expected) {
@@ -183,7 +183,7 @@ Then('a/an/the (value of ){string} should contain/include/be/equal {string}', as
183
183
  let actual = (await locator.element() as HTMLInputElement)?.value ?? ''
184
184
  await expect(actual).toContain(expected)
185
185
  }
186
- })
186
+ }, -10)
187
187
  Then('a/an/the (value of )(the ){string} {word} should contain/include/be/equal {string}', async function (world:VitestBrowserWorld, identifier, role, expected) {
188
188
  let exact = world.info.step?.match(/ should (?:be|equal) ['"]/) ? true : false
189
189
  let locator = await world.getLocator(world.page, identifier, role)
@@ -192,7 +192,7 @@ Then('a/an/the (value of )(the ){string} {word} should contain/include/be/equal
192
192
  let actual = (await locator.element() as HTMLInputElement)?.value ?? ''
193
193
  await expect(actual).toContain(expected)
194
194
  }
195
- })
195
+ }, -10)
196
196
 
197
197
  Then('a/an/the (value of )(the ){string} should not/NOT contain/include/be/equal {string}', async function (world:VitestBrowserWorld, identifier, expected) {
198
198
  let exact = world.info.step?.match(/ should (?:not|NOT) (?:be|equal) ['"]/) ? true : false
@@ -202,7 +202,7 @@ Then('a/an/the (value of )(the ){string} should not/NOT contain/include/be/equal
202
202
  let actual = (await locator.element() as HTMLInputElement)?.value ?? ''
203
203
  await expect(actual).not.toContain(expected)
204
204
  }
205
- })
205
+ }, -10)
206
206
  Then('a/an/the (value of )(the ){string} {word} should not/NOT contain/include/be/equal {string}', async function (world:VitestBrowserWorld, identifier, role, expected) {
207
207
  let exact = world.info.step?.match(/ should (?:not|NOT) (?:be|equal) ['"]/) ? true : false
208
208
  let locator = await world.getLocator(world.page, identifier, role)
@@ -211,37 +211,37 @@ Then('a/an/the (value of )(the ){string} {word} should not/NOT contain/include/b
211
211
  let actual = (await locator.element() as HTMLInputElement)?.value ?? ''
212
212
  await expect(actual).not.toContain(expected)
213
213
  }
214
- })
214
+ }, -10)
215
215
 
216
216
  Then('a/an/the (value of ){string} should be/equal {int}', async function (world:VitestBrowserWorld, identifier, expected) {
217
217
  let locator = await world.getLocator(world.page, identifier, 'input')
218
218
  await expect(locator).toHaveValue(expected)
219
- })
219
+ }, -10)
220
220
  Then('a/an/the (value of )(the ){string} {word} should be/equal {int}', async function (world:VitestBrowserWorld, identifier, role, expected) {
221
221
  let locator = await world.getLocator(world.page, identifier, role)
222
222
  await expect(locator).toHaveValue(expected)
223
- })
223
+ }, -10)
224
224
  Then('a/an/the (value of )(the ){string} should not/NOT be/equal {int}', async function (world:VitestBrowserWorld, identifier, expected) {
225
225
  let locator = await world.getLocator(world.page, identifier, 'input')
226
226
  await expect(locator).not.toHaveValue(expected)
227
- })
227
+ }, -10)
228
228
  Then('a/an/the (value of )(the ){string} {word} should not/NOT be/equal {int}', async function (world:VitestBrowserWorld, identifier, role, expected) {
229
229
  let locator = await world.getLocator(world.page, identifier, role)
230
230
  await expect(locator).not.toHaveValue(expected)
231
- })
231
+ }, -10)
232
232
 
233
233
  // Visual regression testing
234
234
  Then('(the )screenshot/snapshot should match', async function (world:VitestBrowserWorld) {
235
235
  await world.expectScreenshotMatch(world.page)
236
- })
236
+ }, -10)
237
237
  Then('(the )screenshot/snapshot {string} should match', async function (world:VitestBrowserWorld, name:string) {
238
238
  await world.expectScreenshotMatch(world.page, name)
239
- })
239
+ }, -10)
240
240
  Then('(the )screenshot/snapshot of the {string} {word} should match', async function (world:VitestBrowserWorld, identifier, role) {
241
241
  let locator = await world.getLocator(world.page, identifier, role)
242
242
  await world.expectScreenshotMatch(locator)
243
- })
243
+ }, -10)
244
244
  Then('(the )screenshot/snapshot {string} of the {string} {word} should match', async function (world:VitestBrowserWorld, name, identifier, role) {
245
245
  let locator = await world.getLocator(world.page, identifier, role)
246
246
  await world.expectScreenshotMatch(locator, name)
247
- })
247
+ }, -10)