-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
npm test - You should not use <Route> or withRouter() outside a <Router> #36
Comments
I found the solution: Unknown option: base.configFile error when running tests |
But now we have other problem related FAIL src/__tests__/App.test.js
✕ renders without crashing (40ms)
● renders without crashing
Invariant Violation: You should not use <Route> or withRouter() outside a <Router>
6 | it('renders without crashing', () => {
7 | const div = document.createElement('div');
> 8 | ReactDOM.render(<App />, div);
| ^
9 | ReactDOM.unmountComponentAtNode(div);
10 | });
11 |
console.error node_modules/react-dom/cjs/react-dom.development.js:14550
The above error occurred in the <Route> component:
in Route (created by withRouter(Connect(App)))
in withRouter(Connect(App)) (at App.test.js:8)
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 1.466s
Ran all test suites related to changed files. |
francisrod01
changed the title
Error of babel in jest tests
npm test - You should not use <Route> or withRouter() outside a <Router>
Nov 29, 2018
I think this solution works on this project as works on my custom project as well. Create a module.exports = function(api) {
api.cache(true);
const ignore = [/\/(build|node_modules)\//];
const presets = [["@babel/env"], ["@babel/react"]];
const plugins = [
// allow us to use import rather than require
"@babel/plugin-syntax-dynamic-import",
"dynamic-import-node",
// is for code splitting
"react-loadable/babel",
// Support for the experimental syntax 'classProperties' isn't currently enabled
"@babel/plugin-proposal-class-properties"
];
return {
ignore,
presets,
plugins
};
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd try to run test jests in this project but I fail:
The text was updated successfully, but these errors were encountered: