Skip to content

add type checking to asyncAct args #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle case where args[o] is not a string
  • Loading branch information
ely-alamillo committed Aug 30, 2019
commit 9d6677454fb471a0f7bd50a11a97c735c9026a13
33 changes: 19 additions & 14 deletions src/__tests__/old-act.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@ test('async act works even when the act is an old one', async () => {
console.error('sigil')
})
expect(console.error.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
"sigil",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this log is no longer happening. Could you fix your changes so you don't have to change this snapshot?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed implementation to revert back to this snapshot.

],
Array [
"It looks like you're using a version of react-dom that supports the \\"act\\" function, but not an awaitable version of \\"act\\" which you will need. Please upgrade to at least react-dom@16.9.0 to remove this warning.",
],
Array [
"sigil",
],
]
`)
Array [
Array [
"It looks like you're using a version of react-dom that supports the \\"act\\" function, but not an awaitable version of \\"act\\" which you will need. Please upgrade to at least react-dom@16.9.0 to remove this warning.",
],
Array [
"sigil",
],
]
`)
expect(callback).toHaveBeenCalledTimes(1)

// and it doesn't warn you twice
Expand Down Expand Up @@ -101,14 +98,22 @@ test('async act recovers from sync errors', async () => {
test('async act handles values that are not strings', async () => {
try {
await asyncAct(() => {
throw new Error({error: 'test error'})
console.error({message: 'some message'})
})
} catch (err) {
console.error('call console.error')
}
expect(console.error).toHaveBeenCalledTimes(1)
expect(console.error).toHaveBeenCalledTimes(3)
expect(console.error.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
Object {
"message": "some message",
},
],
Array [
"It looks like you're using a version of react-dom that supports the \\"act\\" function, but not an awaitable version of \\"act\\" which you will need. Please upgrade to at least react-dom@16.9.0 to remove this warning.",
],
Array [
"call console.error",
],
Expand Down
4 changes: 2 additions & 2 deletions src/act-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ function asyncAct(cb) {
) === 0
) {
// no-op
} else {
originalConsoleError.apply(console, args)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
} else {
originalConsoleError.apply(console, args)
}

I think that should do it.

} else {
originalConsoleError.apply(console, args)
}
}
let cbReturn, result
Expand Down