茉莉花'期望(...).withContext不是函数'错误 [英] Jasmine 'expect(...).withContext is not a function' error

查看:49
本文介绍了茉莉花'期望(...).withContext不是函数'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种使Jasmine中的故障消息更具描述性的方法,并发现了此功能

I was looking for a way to make failure messaging more descriptive in Jasmine and found this functionality https://jasmine.github.io/api/edge/matchers.html#withContext

所以我在这样的量角器框架中尝试

So I try it in my Protractor framework like this

expect(true).withContext("something else").toBe(false);

运行测试并得到错误- Failed: expect(...).withContext is not a function

此功能自Jasmine 3.3.0起实现,因此我检查了package.json并看到了"jasmine": "^3.3.1",package-lock.json具有

This feature was implemented since Jasmine 3.3.0, so I checked my package.json and see "jasmine": "^3.3.1", and package-lock.json has

"jasmine-core": {
      "version": "3.3.0",

有什么想法吗?

推荐答案

Jasmine团队在GitHub上给出了答案

Just got an answer from Jasmine team on the GitHub stating

量角器使用jasminewd包装器,后者使用Jasmine2.x.如果你想 要使用Jasmine 3.x,可以使用已经发布的Protractor 6.0 最近.在较旧的版本中,Jasmine的最新功能(例如 withContext函数,异步钩子(例如onSpecDone)不可用.

Protractor uses jasminewd wrapper which uses Jasmine 2.x. If you want to use Jasmine 3.x, you can use Protractor 6.0, that has been released recently. In older versions the newest features of Jasmine, like withContext function, async hooks (e.g. onSpecDone) are not available.

除了量角器版本不同外,我发现我的grunt任务运行程序一直在使用grumper-protractor-runner v5.0.0,后者使用了量角器5.4.2.因此,我必须直接使用量角器打开protractor.conf.js.

Besides the difference in Protractor version I found out that my grunt task runner has been using grunt-protractor-runner v5.0.0 which used protractor 5.4.2. So I had to open protractor.conf.js directly with protractor.

这篇关于茉莉花'期望(...).withContext不是函数'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆