Test with real database and get the exception's message


#1

Hi Guys, i came recently to adonisjs, my intention is to create rest API for my project, now i come to the part when i have to test my rest APIs.

my questions is :

  • is there a way to run my test on real database ( i.e. mysql ), because i want to make sure the relationship between tables work perfectly - since i can’t do that with sqlite - already looking inside vowfile.js but i don’t know which line to update and how to update it.

  • can i get message from the exception that i catch from my “try - catch” scope, because i want to return it as error message, instead of returning general error message for all kind of exception.

hope someone here will kindly help me…

thank you very much :smile:


#2

You’re asking a lot in one post?! Did you read the Adonis docs, everything you ask is explained there.

If you want to test on mysql. You need to install mysql on your computer, then configure adonis to use mysql and also install the mysql package with npm install mysql.

To create your own messages, you need to create a custom error handler.

https://adonisjs.com/docs/4.1/exceptions

The Adonis documentation is really clear. I suggest spending a few hours reading it.


#3

ok, thank you very much