how to test back end post request with jest and supertest ?
FrontEnd
fetch("http://localhost:8081/test", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ url }),
})
.then((res) => res.json())
.then((result) => console.log(result)
});
BackEnd
app.post("/test", async (req, res) => {
const url = req.body.url;
const fullUrl = `https://api.meaningcloud.com/sentiment-2.1?key=${API_KEY}&url=${url}&lang=en`;
const response = await fetch(fullUrl);
const data = await response.json();
res.send(data);
});