我正在尝试让 Jasmine 的设置和拆卸方法为我工作。我一定是用错了,因为设置后我无法让变量留在范围内。
不起作用:
describe 'classes/model', ->
beforeEach ->
model = new Model()
describe 'the basics', ->
it 'extends Backbone.Model', ->
expect(model).toBeInstanceOf Model # Fails. 'model is not defined'
我想也许设置必须在描述的范围内。但这也不起作用:
describe 'classes/model', ->
describe 'the basics', ->
beforeEach ->
model = new Model()
it 'extends Backbone.Model', ->
expect(model).toBeInstanceOf Model # Fails. 'model is not defined'
作品。(但不使用设置方便)
describe 'classes/model', ->
describe 'the basics', ->
it 'extends Backbone.Model', ->
model = new Model()
expect(model).toBeInstanceOf Model
我做错了什么会阻止beforeEach
工作吗?