开玩笑的测试-返回值

时间:2019-01-20 11:05:24

标签: node.js jestjs

如何从玩笑测试中返回值?

describe('Return 2 from test1', () => {

 const x = test('test1', async () => {
   return 2;
  });

 test('test2', async () => {
    expect(x).toBe(2);
  });

});

我希望x为2

实际结果是:

{ id: 'spec3',
     description: 'test1',
     fullName: 'Return 2 from test1 test1',
     failedExpectations: [],
     passedExpectations: [],
     pendingReason: '',
     testPath: 'agents.test.ts',
     status: 'failed' },
  currentRun: 
   { cancel: [Function: bound cancel],
     catch: [Function: bound catch],
     then: [Function: bound then] } 
}

0 个答案:

没有答案