How do I debug tests? I tried putting breakpoints and they never hit. Please let me know if there is a way.
What testing framework are you using?
enzyme
Enzyme, mocha, sinon? or Jest, enzyme, sinon?
Jest, enzyme, sinon
You can visit my blog. There is a short 15 min video recorded by the PnP community on it. I hope that can give you more information: https://blog.velingeorgiev.com/unit-test-your-sharepoint-framework-solution-with-jest
Thank you @VelinGeorgiev
Are you using that sample https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-jest-testing?
If yes, bear in mind there is setup you should do. It is in the readme file, but I can add it here as well
Important: The dedug configurations should be placed in the .vscode -> launch.json file to make the debugging work
The sample has folder named vscode where the launch.json configuration for debuggind jest is stored. The configurations should be copied to your .vscode folder -> launch.json file. Once copied into your launch.json, then they will appear in your visual studio code debugging tab.
Yes, I am using that sample. Thanks!
@VelinGeorgiev Could you please share some links on writing tests using Jest, enzyme, sinon framework?
Blogs that use both:
Projects with unit tests:
Samples with tests:
In general, there aren't any jump start tutorials, you will have to dig into samples and learn how the rest did it. I can try help you and answer as much as I can. My plan is to create GitHub readme document with basics, but it is at the bottom of my todo list :(
PS: Mocha and Jest are similar so the samples that use Mocha instead of Jest can also help you do Jest tests better so please do not ignore that piece of content.
@VelinGeorgiev Thank you so much!