testjavascript / nodejs-integration-tests-best-practices

✅ Beyond the basics of Node.js testing. Including a super-comprehensive best practices list and an example app (March 2024)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DB cleanup recepie

goldbergyoni opened this issue · comments

The setup

  • Dedicated folder or even repo
  • Super simple example app in one file - Add & delete order. One column should be unique
  • Single test: Delete order, ensure it was deleted. X100 times (run in a loop to test.each)
  • 20 tables with relationship

The options

  • Option1: Delete all tables on beforeEach
  • Option2: Delete on global teardown occasionally (once a day or with random)
  • Option3: Transactions

Checks and conclusions

  • The performance of each option under 100 tests
  • When cleaning, what is faster: Delete or Truncate
  • The performance of a single process (--run-in-band) vs max-1 processes
  • The RAM impact of having 6 Postgres vs only 1