how to use jest to test sever, db setup in following code

`

const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const cors = require("cors");
const dotenv = require("dotenv");

const app = express();
dotenv.config();

const PORT = process.env.PORT || 8070;
app.use(cors());
app.use(bodyParser.json());
const URL = process.env.MONGODB_URL;

mongoose.connect(URL, {
        

        useNewUrlParser: true,  
        useUnifiedTopology: true
        
});

const connection = mongoose.connection;
const labRouter = require('./routes/lab.js');
app.use("/lab", labRouter);
connection.once("open", () => {
        console.log("Mongodb Connection success!")
});

app.listen(PORT, () => {
        console.log(`Server is up and running on port ${PORT}`)
});`

i want to test server listen on port and mongodb connection. but i am not understand how to write the test code. also i get errors on mocking.