Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda