Closed francisrod01 closed 5 years ago
I found the solution:
Unknown option: base.configFile error when running tests https://github.com/facebook/create-react-app/issues/5259#issuecomment-428455460
But now we have other problem related Route
outside <Router>
.
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.
I think this solution works on this project as works on my custom project as well.
Create a babel.config.js
file in the project's path and then:
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
};
};
I'd try to run test jests in this project but I fail: