我正在尝试在coffeescript中用konacha定义一个辅助方法,就像这样
@expect_int_is_universal = (i) -> expect(i).to.equal 42 describe '#test', -> it 'checks if integer is 42', -> @expect_int_is_universal(42)在konacha有可能吗?
编辑:错误日志在这里:
更新:修复程序将它放在beforeEach块中
beforeEach -> @expect_int_is_universal = (i) -> expect(i).to.equal 42 describe '#test', -> it 'checks if integer is 42', -> @expect_int_is_universal(42)I'm trying to define a helper method in konacha in coffeescript, something like this
@expect_int_is_universal = (i) -> expect(i).to.equal 42 describe '#test', -> it 'checks if integer is 42', -> @expect_int_is_universal(42)Is it possible in konacha?
edit: error log here:
update: the fix is putting it inside a beforeEach block
beforeEach -> @expect_int_is_universal = (i) -> expect(i).to.equal 42 describe '#test', -> it 'checks if integer is 42', -> @expect_int_is_universal(42)最满意答案
mu太短没有成功转换他的评论作为答案,但我将在下面提供:
@(AKA this)里面的回调与顶层不同@所以你将expect_int_is_universal定义为一个对象的方法,但试图将其作为另一个对象的方法。 尝试没有@s。 我不知道Konocha,Mocha还是Chai不仅仅是这么说了
mu is too short hasn't successfully converted his comment as the answer, but i'll provide it here below:
@ (AKA this) inside your it callback is not the same @ as at the top level so you're defining expect_int_is_universal as a method on one object but trying to call it as a method on another object. Try without the @s. I don't know enough Konocha, Mocha, or Chai to say any more than that
更多推荐
发布评论