我尝试以这种方式嵌套它们,并且似乎它停止在 describe("When...spec2 child", function () {
开始的级别。
我想知道 Jasmine 允许嵌套的深度是多少?还是我做错了什么?
describe("ModelSpec", function () {
/*Initial Test Properties*/
var Subject = require('../../lib/jasmine_examples/Model');
var Data = require('../../lib/jasmine_examples/MockData');
var input = new Data();
var model = new Subject(input);//service itself
var mock = {
truthy : true,
falsy : false,
obj : {},
arr : [],
arrOfObj : [ { } ],
nul : null,
undef : undefined,
};
beforeEach(function () {
});
it("Spec 1", function () {
expect(model).toBeDefined();
});
it("Spec 1.2", function () {
expect(model).toBeDefined();
});
describe("When...", function () {
/*
You can initiate another set of test properties vars here
*/
beforeEach(function () {
});
it("Spec 2", function () {
expect(model).toBeDefined();
describe("When...spec2 child", function () {
beforeEach(function () {
});
it("Spec 2 child", function () {
});
});
});
it("Spec 3", function () {
expect(model).toBeDefined();
expect(input.id).toBeDefined();
});
});
最佳答案
您不能将describe
放入it
中。嵌套没有固定限制。
作品:
describe("...", function() {
describe("...", function() {
it("...", function() {
// ...
});
describe("...", function() {
// ...
});
});
});
不起作用:
describe("...", function() {
describe("...", function() {
it("...", function() {
describe("...", function() {
// ...
});
});
});
});
关于javascript - Jasmine 允许深度嵌套描述套件有多深?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32211631/