Jasmine Testing 获取名称的完整描述/它的

标签 jasmine protractor

我想知道,是否可以获得测试的完整嵌套描述路径?

给定:

describe('Smoke Testing - Ensuring all pages are rendering correctly and free of JS errors', function () {
  describe('app', function () {
    describe('app.home', function () {
      it('should render this page correctly', function (done) {
        //name here should be: Smoke Testing - Ensuring all pages are rendering correctly and free of JS errors app app.home should render this page correctly
        done()
      })
    })

    describe('app.dashboard', function () {
      describe('app.dashboard.foobar', function () {
        it('should render this page correctly', function (done) {
        //name here should be: Smoke Testing - Ensuring all pages are rendering correctly and free of JS errors app app.dashboard app.dashboard.foobar should render this page correctly    
          done()
        })
      })
    })

  })

})

最佳答案

jasmine.Suitejasmine.Spec 都有方法 getFullName()。如您所愿地工作:

describe("A spec within suite", function() {
  it("has a full name", function() {
    expect(this.getFullName()).toBe('A spec within suite has a full name.');    
  });
  
  it("also knows parent suite name", function() {
    expect(this.suite.getFullName()).toBe('A spec within suite');    
  });
});
<script src="http://searls.github.io/jasmine-all/jasmine-all-min.js"></script>

注意:这个答案现在有点过时了,示例中使用的是 Jasmine 1.3.1。

关于Jasmine Testing 获取名称的完整描述/它的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24791817/

相关文章:

angularjs - 如何在 Protractor 测试中获取页面上的所有内容/文本?

javascript - 如何从 element.all every 返回一个元素

javascript - Protractor - 在对话框容器中向下滚动以单击元素

javascript - 单击按钮捕获滚动

javascript - Protractor 中的元素不可见错误

javascript - 如何在服务中测试 $location 和 .search()

ajax - 获取 jquery 中最后一次 ajax 调用

javascript - Protractor 看不到元素的子元素

angularjs 1 和 jasmine,服务 promise 测试

javascript - Protractor Jasmine 规范描述中的浏览器功能