我想知道,是否可以获得测试的完整嵌套描述路径?
给定:
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.Suite 和 jasmine.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/