代码之家  ›  专栏  ›  技术社区  ›  Noitidart

`在“hook而不是测试用例(`it`)”之前

  •  0
  • Noitidart  · 技术社区  · 6 年前

    摩卡咖啡不允许里面有钩子吗 it 测试用例?

    我试过以下的方法,但似乎没有成功:

    describe('Array', () => {
    
      before(async () => {
          // do some async stuff before any test cases in this suite run
          // THIS RUNS OK
      });
    
      it('should blah', async () => {
          before(async () => {
              // do some async stuff just before this test case
              // THIS NEVER RUNS!!!!!!!!!!!!!!!!!!!!!!
          });
    
          // blah
      );
    
    });
    

    这个 before 立即在 describe 跑,但是 之前 就在里面 不运行。

    0 回复  |  直到 6 年前
    推荐文章