How to convert below code with mock data? Below is the testing code of NodeJs post call api.
const request = require('supertest') const app = require('../server') describe('Post Endpoints', () => { it('should create a new post', async () => { const res = await request(app) .post('/api/posts') .send({ userId: 1, title: 'test is cool', }) expect(res.statusCode).toEqual(201) expect(res.body).toHaveProperty('post') }) })
2.1m questions
2.1m answers
60 comments
57.0k users