用箭头功能测试对象

时间:2017-02-14 17:27:17

标签: javascript ecmascript-6 jestjs arrow-functions

当我使用jest常用功能时,我可以访问this中的测试对象。<​​/ p>

afterEach(function() {
  return this.hello; // 'Hello world!'
})

it(function() {
  this.hello = 'Hello world!';
})

当我使用箭头功能时,this表示全局背景。

当我使用箭头功能时,如何访问测试对象?

0 个答案:

没有答案