本文介绍了如何jasmine.getenv()。currentspec与茉莉花2.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在执行每个规范后获得测试的通过或失败状态:

I want to get the passed or failed status of my test after each spec is executed:

var passed = jasmine.getEnv().currentSpec.results().passed();
      if (!passed) {
        browser.takeScreenshot().then(function(png) {
          writeScreenShot(png, filename, path);
        };
      }

但是 jasmine.getEnv()。currentSpec 正在返回 undefined ,我正在使用Jasmine 2.3如何使用Jasmine 2.3获取 currentSpec

but jasmine.getEnv().currentSpec is returning undefined, I am using Jasmine 2.3 how can I get the currentSpec with Jasmine 2.3

推荐答案

你可能是从当前规范之外调用它。 jasmine.getEnv()。currentSpec 将为null,例如,如果在中调用afterAll beforeAll 块。确保在规范的上下文中调用此代码。

It's likely that you are calling this from outside of the current spec. jasmine.getEnv().currentSpec will be null if there is no current spec, for example if it is called in afterAll or beforeAll blocks. Make sure that this code is invoked in the context of a spec.

如果没有看到更多上下文,我无法确认这是问题,但这看起来像它。

I can't confirm that this is the problem without seeing more context, but this looks like it.

这篇关于如何jasmine.getenv()。currentspec与茉莉花2.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 16:05