是否支持将第二个参数传入 Jasmine 的 toBe 匹配器中?

Jas*_*Lee 2 jasmine

我从 Angular 的文档中找到了这个代码片段,但在 Jasmine 的文档中找不到这个用法。这真的是受支持的功能吗?我只是想确保如果我使用此功能,在升级到较新的次要/补丁版本时它不会意外中断。

expect(masterService.getValue())
.toBe(stubValue, 'service returned stub value');
Run Code Online (Sandbox Code Playgroud)

wat*_*ova 5

从 3.3 开始支持的方法是 withContext: https: //jasmine.github.io/api/edge/matchers.html#withContext

expect(masterService.getValue()).withContext('service returned stub value')
.toBe(stubValue);
Run Code Online (Sandbox Code Playgroud)