How to run concurrent tests in Jest with multiple tests per request?

前端 未结 2 919
旧巷少年郎
旧巷少年郎 2021-01-20 21:53

I\'d like to run my Jest tests concurrently, but I\'m having issues with one scenario:

I\'m testing the results on an endpoint, and I want to test multiple things ab

2条回答
  •  误落风尘
    2021-01-20 22:12

    Seems worth pointing out, that there is also a discussion about this in a jest issue: https://github.com/facebook/jest/issues/4281

    Gist of it: It doesn't work that way and isn't planned. Possible workaround:

    const dataPromise = getSomeDataPromise();
    
    test.concurrent('one', async () => {
      const data = await dataPromise;
    });
    
    test.concurrent('two', async () => {
      const data = await dataPromise;
    });
    

提交回复
热议问题