如何使用模拟数据在代码下工作

问题描述

如何用模拟数据转换下面的代码?下面是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')
  })
})

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)