I just started learning jest today, and I've read that you shouldn't hit actual api endpoints because its slow, or it's not standard practice. Instead you create mocks that represent the data you would get returned?
if the purpose of testing the route was to see if it worked, wouldn't making a mock of the data defeat the purpose. I guess I'm just confused by all the beginners guides and the Jest documentation is a bit over my head.
My question is should I test my routes files for my node server, also how I would go about testing my routes file for my node server. if my route looks like this:
// routes.js
const express = require('express');
const router = express.Router();
const axios = require('axios')
// my backend is connected to another api in this project
router.get('/', (req,res) => {
axios.get('https://jsonplaceholder.typicode.com/users/1').then(data => res.json(data.data))
})
please I've read the docs it hasn't helped could you give me a specific example