konacha

编程入门 行业动态 更新时间:2024-10-25 08:26:04
konacha - 辅助方法coffeescript(konacha - helper methods coffeescript)

我正在尝试在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

更多推荐

本文发布于:2023-07-28 23:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1310156.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:konacha

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!