# Integration Test Guide ## Why? - we are slow shipping new features and fixing old stuff. ## Ideas - Throw e2e()-away - Let a fixture do the setup - Keep the mongo-setup in the jest - Investigating how .jest-cache can be used better - https://benlimmer.com/2021/01/29/circleci-jest-cache/ - Currently, we migh not even read the cache? [Raw Log](https://storage.googleapis.com/gitlab-gprd-artifacts/6f/79/6f79674f0d464fa8f1fe109a2fe3821eee123b9caa61e21fcff2f771258d60ef/2022_10_20/3203197375/3490663097/job.log?response-content-type=text%2Fplain%3B%20charset%3Dutf-8&response-content-disposition=inline&GoogleAccessId=gitlab-object-storage-prd@gitlab-production.iam.gserviceaccount.com&Signature=SdNfn%2FqfjsiNkO%2BMDkIsE1QXeaO2In%2BcQgJjS%2Fyi7wYArRxi53jo%2FQFnwaZM%0ARG%2FUmwsa66YWi9yiJxvkTIsjHHv5CLYmuTYGq9gpUDQXDbogFbePfIhZtaus%0Az1sKg94l3wk6IfdNH%2B3pKbt8veUHpknMpCnJuZcqaVrLJj5PFC5B6lWyEFwv%0AfvBenNdQp6j06wVCq40Wx30dLx8YgKq4K5R0IvjVJWRPet8jiLOz%2BIk5xzS8%0AlKEOvfysq%2FkHKllzwnfMg7SJVsnB069jCHkE0M9CPLCQHak%2BQzzwz1X1H188%0AFLJSkVaZHQjBzmIMxwJrzDvcV645u6P3uhOTWC5opg%3D%3D&Expires=1666437003) - How long does the cache live? - Where does the cache apply (per branch? per repo? per Merge Request?) - Are over 180 thousand files a good shape for the cache? - Try `pactum` instead of `supertest`: [Example](https://github.com/jmcdo29/nest-e2e-sample/blob/main/test/person/person.spec.ts) - Run all tests in parallel - Therefore: Stop clearing the whole DB, but using randomized test-data - Use pactum for testdata clean-up if needed - Challange MockMSServiceController - It hides a lot - Developer needs much logic in order to understand which role MockMSServiceController plays - Since the data is static sometimes it is hard to configure the data for scenarios expecting different test data ## Goals - Simplify & standardize way to write Integration Tests - Make Integreation tests clear and readable - Avoid unneeded duplications - Improve Testperformance - Reduce memory usage by 50% - Reduce test run time by 50% ## Strategies - One NestJS App per test (current behaviour) - One NestJS App for all tests ## General thoughts - Avoid technical terms in tests. - Technology changes quicker than business invariants. ```ts // Explain which business context is tested describe('Transportation Order', () => { // Explain the business case by describing a certain situation describe('When a new transportation order is received', () => { // Explain your expectation in detail it('ignores the transportation order if no yard is configured', () => { }). }) }) ```