question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

testing in react-create-app stack

See original GitHub issue

Hi. I’m using CRA, with mobx, react-router@4 and this project.

In the app itself everything goes well. I have routerStore like example, and I pass history prop to Router. I need withRouter for every component that uses this functionality but that’s fine.

The problem starts at testing, I manage to change path from the app (with simulate click on some btn that do props.history.push('..') ) with function assertCorrectPath(ev) { expect(ev).toEqual('/'); } MainWrapper.context().router.history.listen(assertCorrectPath); I have it on context thanks to: react-router-test-context.

But, I cannot be in sync with path when I change it from the test: I do wrapper.context().router.history.push('cc'); and the Component is not rendered accordingly.

Is there any easier way for all that?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
yonatanmncommented, Apr 20, 2017

file at stores/Router is:

import { RouterStore, syncHistoryWithStore } from 'mobx-react-router';

import createBrowserHistory from 'history/createBrowserHistory';
const browserHistory = createBrowserHistory();

const router = new RouterStore();
export const history = syncHistoryWithStore(browserHistory, router);

export default router;
0reactions
yonatanmncommented, May 3, 2017

ok , ill try. thx

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing Overview - React
Running a complete app in a realistic browser environment (also known as “end-to-end” tests). This documentation section focuses on testing strategies for ...
Read more >
How to test React Apps | BrowserStack
A detailed guide on how to test React Apps, including examples of Unit Testing and Component Testing using JEST and React Testing Library....
Read more >
Testing a Full-Stack React Application - Frontend Digest
react -testing-library is a lightweight solution for testing React components. It provides utility functions on top of react-dom and react-dom/test-utils . When ...
Read more >
Fullstack part5 | Testing React apps - Full stack open
Create -react-app configures tests to be run in watch mode by default, which means that the npm test command will not exit once...
Read more >
Implementing Tests - Fullstack React
The create-react-app package sets up a quality testing environment using Jest automatically for us. We can execute our tests by using the yarn...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found