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

102
Views
Creating a function that insert data into a posgreSQL database the TDD way using jamine

I am trying to create a function that adds data into a posgreSQL database using javascript the TDD way but then I find it difficult to write a test that checks if the function has really inserted data into the database here is my code

require("dotenv").config();
const Pool = require("pg").Pool;
const pool = new Pool({
  user: process.env.User,
  host: process.env.HOST,
  database: process.env.DB,
  password: process.env.PASSWORD,
  port: process.env.PORT,
});

const addNewVisitor = (name, age, date, time, assistor, comment) => {
  
  pool.query(
    `INSERT INTO Visiters(visitorName,visitorAge,dateOfVisit,timeOfVisit,nameOfThePersonWhoAssistedTheVisitor,comments)VALUES($1,$2,$3,$4,$5,$6)`,
    [name, age, date, time, assistor, comment],
    (error) => {
      if (error) {
      
        console.log(error);
      }
      console.log("Visitor added");
    }
  );
  
};

about 4 years ago · Juan Pablo Isaza
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!