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
Add a test to the test suite confirming that Account.create() works in React Native env #12
Comments
This makes sure that the shims we used with |
I've tried to make a test case that we can be check is a new address created by Tasit SDK, assuming if that is created, ethers.js is working properly. My first attempt was create a pure Jest test case with snapshot but I've faced a problem because componentDidMount (who calls Account.create) is async, and because that snapshot is write without wallet address. Because I haven't found a simple solution for this issue and not sure about which test tools we'll go to use, I've jumped to try use jest-enzyme-shallow. I've handled async issue with enzyme but I'm not sure if this is better solution.
What do you think @pcowgill ? After that other problem emerged: Enzyme don't support React 16 completly yet: At both of attempts the error above occurs: @pcowgill Do you have faced some of these problems before? Any tip? Which test tools setup we should use? Both WIP branches: jest snapshots and enzyme |
@marcelomorgado Thanks for this detailed info! That test case is what I was picturing. I think in general having as many shallow tests as possible is considered good practice. For most smaller components that change based on variable data, we can test those just by faking that data as input to a pure component. So we won't have too many tests where we need to manually call componentDidMount to trigger data generation. Enzyme is what I've used in the past when I do need to manually interact with the virtual DOM. So let's mostly use the non-Enzyme approach, but use Enzyme for this specific case you brought up. (So that would mean using a little of both open WIP branches). In the Enzyme README they say Enzyme v3 is supposed to support React 16. I followed through that path of comments you linked to. Let's create an issue to remember to remove the modifiied preprocessor whenever they get this working. I haven't encountered this particular issue with react-native before, mostly because I've mostly worked with older versions. Here are some slides I like on testing React (and React Native) applications https://docs.google.com/presentation/d/1VRyWAZ0qSmJgcCEpl7XX68eoVf7890H1nkPWM0jkToY/edit#slide=id.p5 |
@marcelomorgado Given that info, which WIP branch will you plan on working on? |
Thank you for the slide! |
That sounds great! |
Snapshots I’ve found three ways to do that:
I’ve used Jest+Enzyme to generate snapshots. Motivations:
It isn’t working perfectly yet. There is a caveat: Snapshots don’t recognize some react-native components (i.e., View, Image are saved as Component)? Refs |
Enzyme simulate press w/ async function I’ve faced the problem related to this issue:
EthereumSignUpForm.test.js
EthereumSignUpForm.js
Output
Solution: Worked when calling the component function directly an then check address state value. |
A) Thanks for the context on the choice between react-test-renderer create, react-test-renderer shallow, and Enzyme shallow. I think you made the right call. |
A) 👍
Yes, I think that it's worth, how is the better way to do that? Creating a Thanks! |
C) I think let's merge #29, I'll create an issue for swapping the test to using the button press, and yeah this can come in a new branch off of develop after I merge that PR. What did you mean by "reproduce all environment"? |
Keep same setup, dependencies, versions. |
No description provided.
The text was updated successfully, but these errors were encountered: