Friday, 11 January 2019

Testing structure and what and how to test

Hey guys,Recently I've been working on my test skills. I can code but never really tested my code using unit/e2e tests. Now I've been working on some small projects to get the hang of it but I don't really feel confident yet. On the internet you can find plenty of stuff on how to get started with Jest, Mocha & Chai etc.. Jest actually talks about structure in your project so that's nice. You could either dump all your tests in a test directory next to your source directory which has a similar structure or add your tests next to your actually source files.So far I understand that. To be more concrete. I've a small Node application and started doing TDD to practice my test skills with just Jest. I've created a test directory and tests are working fine (BDD style using describe and it). Now I'm at the point I'd like to add a database connection using Mongo/Mongoose. How should I proceed? Is this actually more of an e2e test? How should I proceed on this? What is best practise? I can't find a good example on GitHub or on websites. I can find plenty of website that talk about how to test your mongoose models etc, those seem really unit tests to me and I understand that but how about tests for the actual connection? Should I use other tooling for e2e tests?Hope you guys/gals can help me out in my journey to become a better developer ;) .

Submitted January 11, 2019 at 10:12AM by zwik

No comments:

Post a Comment