I’m looking for some assistance with testing my react app. I’m currently on the practice project: Jammming in the Career Path “Front end engineer”. I’m almost done, but I want to run some unit tests, but I can’t get Mocha to work with React. One of the ToDo’s in the project is testing and debugging.
This is the issue, the only way I have learned unit testing is with Mocha earlier in the Career Path “Front end engineer”.
I’ve tried to install loads of npm packages to combat the issues surrounding Mocha unit testing in React, but now I’m at a loss (I’m probably too noob to get it ). What do I do with the unit testing? Should I skip through and wait with testing until I get to the Jest-course in the Career Path? (and in that course “Enzyme” is mentioned, and that’s deprecated)
Writting tests for your code is an important skill as a software engineer. Not only does it help create shippable code, it will also help you in your future studies. Without testing, you’ll have to manually test your code every time you make a change that can break the app. Now, you might be thinking “break” as in your code causes the app to crash. This, ironically, is ideal, but in reality your code can break a small aspect of your code that you will probably miss in your manual tests.
What exactly is the issue? Do you have a github repo? Might be worth attending a chapter to get some help!
My issue is that the only testing skill I have acquired, during the Career Path “Front end engineer”, is testing with Mocha. And in React, I can’t get Mocha to work. It seems like Mocha isn’t compatible with React, or something. It doesn’t seem possible to e.g. use import instead of require, and when I’ve installed loads of recommended npm packages, I’m not able to test nested functions inside the components, e.g. in App.js.
So basically, I’m wondering how I’m supposed to write the unit tests with the skills I’ve learned during the Career Path “Front end engineer”?