Skip to content

fix: improve error message when auto-detection fails to mention bundlers #548

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
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ The standard import looks like:
import { renderHook } from '@testing-library/react-hooks'
```

> Note: The auto detection function may not work if tests are bundles before execution (e.g. to be
> run in a browser)
> Note: The auto detection function may not work if tests are being bundled (e.g. to be run in a
> browser)

### Act

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/defaultRenderer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('default renderer', () => {
})

const expectedMessage =
"Could not auto-detect a React renderer. Are you sure you've installed one of the following\n - react-dom\n - react-test-renderer"
"Could not auto-detect a React renderer. Are you sure you've installed one of the following:\n - react-dom\n - react-test-renderer\nIf you are using a bundler, please update you imports to use a specific renderer. For instructions see: https://react-hooks-testing-library.com/installation#being-specific"

expect(() => require('..')).toThrowError(new Error(expectedMessage))
})
Expand Down
2 changes: 1 addition & 1 deletion src/pure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function getRenderer() {
.join('\n')

throw new Error(
`Could not auto-detect a React renderer. Are you sure you've installed one of the following\n${options}`
`Could not auto-detect a React renderer. Are you sure you've installed one of the following:\n${options}\nIf you are using a bundler, please update you imports to use a specific renderer. For instructions see: https://react-hooks-testing-library.com/installation#being-specific`
)
}
}
Expand Down