Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Testing NodeJS and SQL database integration

What would be the best practice setup for running tests that involved some integration of a NodeJS API and a database?

In addition to unit tests, it'd be great if I could seed the database with some dummy data and test various behaviors on this data.

In these cases is it best to have a test database sitting there solely for the purpose of testing? E.g. in AWS there'd be an RDS instance always on, that CI tools would point to and have permissions for.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

What I tend to do here is to create fixture objects that represent common objects I'd use to test. So a Car model might have a Camero fixture object, that I then instantiate in my unit tests to do something with.

Read this as: I create any objects I need to test with in the unit tests themselves, then make sure to delete the data after my test. I don't pre-populate the database with test objects, because I may want to create a Red Camera, or a Camero With Three Wheels Camero for some test I'm doing.

For MEAN apps in the past I've had good luck with FactoryLady. It claims it only assumes a "save" method exists on your objects, so it should be usable with some SQL ORM you're using.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!