1. Styles
1.1. others
1.1.1. styles
1.1.1.1. bad
1.1.1.1.1. Very bad
1.1.1.2. good
1.1.1.2.1. very good
1.1.1.3. not as good
1.1.1.4. not as bad
1.1.1.5. important
1.1.1.5.1. Very important
1.1.1.6. warning
1.1.1.7. link
1.1.2. AUTHOR
1.1.2.1. Nima Shokouhfar
1.1.2.1.1. Linkedin
1.1.2.1.2. Youtube
1.1.2.1.3. Medium
1.1.2.1.4. Github
1.1.2.1.5. upwork
1.1.2.1.6. main website: ideariver.ca
1.1.3. Styling Version
1.1.3.1. 3.0.1
1.2. main
2. main
2.1. CI/CD pipeline
2.1.1. avoid pushing disfunctional code to the server
2.2. why
2.2.1. why write test?
2.2.1.1. CHATPGT Era & code generators era
2.2.1.1.1. We all use chatgpt to write code these days. However, these tools are not perfect and make stupid mistakes that human can never catch
2.2.1.1.2. So, if you use these tools and not writing test, the system can get unstable very fast
2.2.1.1.3. This is why I believe writing test in our time is the matter of utmost importance
2.2.1.2. refactoring
2.2.1.2.1. When changing the code, you do not create a time bomb
2.2.1.3. Maintenance
2.2.1.3.1. Passing to other engineers
2.2.1.4. automated test
2.2.1.4.1. especially, for multiple instances of same class
2.2.1.4.2. plugin systems
2.2.1.4.3. Sometimes, it is faster to test a functionality by automated tests than doing it manually
2.2.1.5. Atomic system
2.2.1.5.1. when you write test from small units to large fully integerated one, it becomes extremely easy to find where the code broke very fast
2.2.1.6. catch bugs that are extremely difficult to create manually
2.2.1.7. Performance testing
2.2.1.7.1. Execution time testing
2.2.1.7.2. This is by default, remember openi-ai god object case
2.2.1.8. BTW, it is much easier to test something in debugging environment than actuall environment
2.2.1.8.1. debug is the best, compare to console logs. man without any doubts
2.3. Lesson learned
2.3.1. Static and singelton patterns are horrible for test
2.3.1.1. since they are global previous tests can manipulate the state of the test. and mess each other up
2.3.2. for exceptopns use finally to clear after the fact
2.3.2.1. example
2.3.3. Don't do try catch like this
2.3.4. Read the comments and remove the garabage
2.3.4.1. example
2.3.4.1.1. meaningless note
2.3.5. Nikolay wisdom
2.3.5.1. control type of exception
2.3.5.1.1. var ex = Assert.ThrowsException<Exception>( () => ConfigLocationHelper.MoveConfigFile(nonExistentPath, newPath), "Expected exception was not thrown when moving a non-existent file.");
2.4. AAA Arrange, Act and Assert
2.5. Docker testing
2.5.1. test with docker
2.6. test pyramid
2.6.1. unit testing
2.6.2. integration test
2.6.3. end to end test
2.7. tricks
2.7.1. asnyc
2.7.1.1. test
2.7.1.1.1. solution
2.7.1.2. how to do
2.7.1.3. when you have async calls in your code
2.8. Don't use this pattern
2.9. Supertest
2.9.1. login
2.9.1.1. session/ agent
2.9.1.1.1. Session Persistence
2.9.1.1.2. Simulates Real-World User Sessions
2.9.1.1.3. npm install supertest@latest superagent@latest --save-dev