TDD with NestJS

Thiago Zilli Sarmento

2020 May

So why TDD test?

Just a few reasons (of many)...

 

Find bugs early...

 

Find regressions before someone else finds them...

 

Supports easier implementation refactoring...

 

Pseudo documentation in code...

 

etc...

Responsibility of test

Just a few reasons (of many)...

 

 

Tests must be part of Continuous Integration...

 

 

Tests must be part of Continuous Deploy...

 

 

Tests must be part of work flow... (sap)

 

Test Driven Development (TDD)

What to test?

 

Database interactions...

 

API endpoints (end-to-end)...

 

Metrics...

 

• Test A and Test B behavior... and more

 


70% code coverage is required for basic metrics!

Testing Principles

 

 

Avoid having side effects in your functions

 

Tests should NOT rely on testing order (run independently)


Tests should be repeatable


Bogus your inputs

 

Thanks

 

 

Resorces

 

https://nestjs.com/


https://jestjs.io/


https://github.com/visionmedia/supertest

 

 

 

Made with Slides.com