Testing mysql API and nodejs integration

Asked

Viewed 57 times

0

I have an API written in Nodejs (express) that uses the library mysql to pull data from a database hosted on AWS.

API endpoints are basically SQL queries, almost without logic associated with data return.

I would like to test this API to see if it behaves well with null, invalid fields, etc. but I don’t want to use the production database for this.

I must create a new database identical to the original, put it in the cloud and use it for testing or if there are any better suggestions?

  • 1

    for unit test need not database, make a mock of the database, otherwise it will not be a unit test

  • Please explain better @Ricardopunctual how this would be done? What library? Remembering that it has almost no logic, the idea would be to test if the query is behaving as expected for different entries in the database

  • if you want to test the query in the database is not a unit test. Unit test a single class, a method

  • Okay, I’ll switch to integration testing, it’s more appropriate to the question?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.