Skip to content

Commit edfb241

Browse files
committed
CR: shorter timeouts and wait times for quicker tests
1 parent 414a3dc commit edfb241

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/__tests__/wait-for-element.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ test('it throws if timeout is exceeded', async () => {
173173

174174
const promise = waitForElement(callback, {
175175
container,
176-
timeout: 300,
176+
timeout: 70,
177177
mutationObserverOptions: {attributes: true},
178178
}).then(successHandler, errorHandler)
179179

@@ -182,14 +182,14 @@ test('it throws if timeout is exceeded', async () => {
182182
expect(errorHandler).toHaveBeenCalledTimes(0)
183183

184184
container.setAttribute('data-test-attribute', 'something changed once')
185-
await skipSomeTimeForMutationObserver(200)
185+
await skipSomeTimeForMutationObserver(50)
186186

187187
expect(callback).toHaveBeenCalledTimes(2)
188188
expect(successHandler).toHaveBeenCalledTimes(0)
189189
expect(errorHandler).toHaveBeenCalledTimes(0)
190190

191191
container.setAttribute('data-test-attribute', 'something changed twice')
192-
await skipSomeTimeForMutationObserver(150)
192+
await skipSomeTimeForMutationObserver(50)
193193

194194
expect(callback).toHaveBeenCalledTimes(3)
195195
expect(successHandler).toHaveBeenCalledTimes(0)
@@ -209,7 +209,7 @@ test('it throws the same error that the callback has thrown if timeout is exceed
209209

210210
const promise = waitForElement(callback, {
211211
container,
212-
timeout: 300,
212+
timeout: 70,
213213
mutationObserverOptions: {attributes: true},
214214
}).then(successHandler, errorHandler)
215215

@@ -218,14 +218,14 @@ test('it throws the same error that the callback has thrown if timeout is exceed
218218
expect(errorHandler).toHaveBeenCalledTimes(0)
219219

220220
container.setAttribute('data-test-attribute', 'something changed once')
221-
await skipSomeTimeForMutationObserver(200)
221+
await skipSomeTimeForMutationObserver(50)
222222

223223
expect(callback).toHaveBeenCalledTimes(2)
224224
expect(successHandler).toHaveBeenCalledTimes(0)
225225
expect(errorHandler).toHaveBeenCalledTimes(0)
226226

227227
container.setAttribute('data-test-attribute', 'something changed twice')
228-
await skipSomeTimeForMutationObserver(150)
228+
await skipSomeTimeForMutationObserver(50)
229229

230230
expect(callback).toHaveBeenCalledTimes(3)
231231
expect(successHandler).toHaveBeenCalledTimes(0)
@@ -249,7 +249,7 @@ test('it returns immediately if the callback returns the value before any mutati
249249

250250
const promise = waitForElement(callback, {
251251
container,
252-
timeout: 300,
252+
timeout: 70,
253253
mutationObserverOptions: {attributes: true},
254254
}).then(successHandler, errorHandler)
255255

@@ -265,7 +265,7 @@ test('it returns immediately if the callback returns the value before any mutati
265265
expect(errorHandler).toHaveBeenCalledTimes(0)
266266

267267
container.setAttribute('data-test-attribute', 'something changed once')
268-
await skipSomeTimeForMutationObserver(200)
268+
await skipSomeTimeForMutationObserver(50)
269269

270270
// No more calls are expected.
271271
expect(callback).toHaveBeenCalledTimes(1)

0 commit comments

Comments
 (0)