Skip to content

Commit 414a3dc

Browse files
committed
CR: await promise -> return promise
@kentcdodds: > Rather than `await promise`, I'd prefer `return promise`. Maybe I'm being irrational here, but it feels better to me. @sompylasar: > I'm changing this, but if this line was the only one with `await` expression, then `eslint` would say `async` function must have an `await`. We are lucky that there are more `await`s in all the tests. > > P.S. I don't agree with this rule because `async` functions have their use for the error handling; `async` function is just the one that is wrapped in a `return new Promise(...)`.
1 parent 1252d08 commit 414a3dc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/__tests__/wait-for-element.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ test('it waits for the callback to return a value and only reacts to DOM mutatio
9797
expect(container).toMatchSnapshot()
9898
expect(testEl.parentNode).toBe(container)
9999

100-
await promise
100+
return promise
101101
})
102102

103103
test('it waits for the next DOM mutation with default callback', async () => {
@@ -126,7 +126,7 @@ test('it waits for the next DOM mutation with default callback', async () => {
126126
expect(errorHandler).toHaveBeenCalledTimes(0)
127127
expect(document.body).toMatchSnapshot()
128128

129-
await promise
129+
return promise
130130
})
131131

132132
test('it waits for the attributes mutation if configured', async () => {
@@ -161,7 +161,7 @@ test('it waits for the attributes mutation if configured', async () => {
161161
expect(successHandler).toHaveBeenCalledWith('PASSED')
162162
expect(errorHandler).toHaveBeenCalledTimes(0)
163163

164-
await promise
164+
return promise
165165
})
166166

167167
test('it throws if timeout is exceeded', async () => {
@@ -197,7 +197,7 @@ test('it throws if timeout is exceeded', async () => {
197197
expect(errorHandler.mock.calls[0]).toMatchSnapshot()
198198
expect(container).toMatchSnapshot()
199199

200-
await promise
200+
return promise
201201
})
202202

203203
test('it throws the same error that the callback has thrown if timeout is exceeded', async () => {
@@ -233,7 +233,7 @@ test('it throws the same error that the callback has thrown if timeout is exceed
233233
expect(errorHandler.mock.calls[0]).toMatchSnapshot()
234234
expect(container).toMatchSnapshot()
235235

236-
await promise
236+
return promise
237237
})
238238

239239
test('it returns immediately if the callback returns the value before any mutations', async () => {
@@ -274,5 +274,5 @@ test('it returns immediately if the callback returns the value before any mutati
274274

275275
expect(container).toMatchSnapshot()
276276

277-
await promise
277+
return promise
278278
})

0 commit comments

Comments
 (0)