Skip to content

Commit 05aa661

Browse files
committed
refactor: address pr feedback
1 parent bde4cf5 commit 05aa661

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/__tests__/wait-for.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {renderIntoDocument} from './helpers/test-utils'
12
import {waitFor} from '../'
23

34
test('waits callback to not throw an error', async () => {
@@ -34,7 +35,11 @@ test('uses generic error if there was no last error', async () => {
3435
})
3536

3637
test('throws nice error if provided callback is not a function', () => {
37-
expect(() => waitFor('not a function')).toThrow(
38+
const {queryByTestId} = renderIntoDocument(`
39+
<div data-testid="div"></div>
40+
`)
41+
const someElement = queryByTestId('div')
42+
expect(() => waitFor(someElement)).toThrow(
3843
'Received `callback` arg must be a function',
3944
)
4045
})

src/wait-for.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function waitFor(
2323
} = {},
2424
) {
2525
if (typeof callback !== 'function') {
26-
throw new Error('Received `callback` arg must be a function')
26+
throw new TypeError('Received `callback` arg must be a function')
2727
}
2828

2929
// created here so we get a nice stacktrace

0 commit comments

Comments
 (0)