Design the Database Connection
The app.js file will call a connect function to set the database connection on application start. The rest of the code may call a get function to get the connection. The close function will help to close the database connection. The application may not have a use for the close function during normal executionâthe connection is created on start-up and is kept throughout the execution. However, weâll still design this function because it will be needed to ensure the connections in the connection pool are closed properly during testing. Letâs design those functions, test first, starting with the get function. In the test list, the first test says the get function will return null by default. Letâs write the ...
Get Test-Driving JavaScript Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.