小编Olg*_*del的帖子

Jest 不等待 async beforeAll 完成

我正在尝试测试从我的 REST API 获取所有用户。

describe('GET', () => {
    let userId;

    // Setup create the mock user
    beforeAll(async () => {
      //Create the user
      return await request
          .post(routes.users.create)
          .set('Accept', 'application/json')
          .send(TEST_USER_DATA)
          .then(res => userId = res.body.id)
    })

    // Clean up, deleting all the fake data that we created for this test suite
    afterAll(async () => {
      // Clean up, delete the user we created
     return await request.delete(routes.users.delete(userId));
    })

    it('should get all users', async () => {
      const usersResponse = await request …
Run Code Online (Sandbox Code Playgroud)

asynchronous supertest jestjs e2e-testing

6
推荐指数
0
解决办法
2850
查看次数

标签 统计

asynchronous ×1

e2e-testing ×1

jestjs ×1

supertest ×1