茉莉花 - 只有“它”阻止跑步

时间:2016-04-26 18:40:10

标签: unit-testing jasmine karma-runner karma-jasmine

我有几种这种格式的测试用例。

describe("", () => {
    console.log("describe1");
    beforeEach(() => {
        console.log("beforeEach");
    });

    describe("", () => {
        console.log("describe2");
        it("", () => {
            console.log("it1");
        })

        it("", () => {
            console.log("it2");
        })
    });
});

我遇到的问题是我让每一个测试都运行得很好,但是当所有测试都运行完毕后,它再次运行每个测试,但没有运行beforeEach块,这使我的测试失败。

所以上面的代码会打印出来......

describe1
describe2(note that the "it"s are not executed)
beforeEach
it1
beforeEach
it2(so far so good but now...)
it1(notice how before each didn't run but the "it"s were reran here and below)
it2

所以我不理解为什么it1和it2在没有之前的情况下再次运行。

注意:我正在使用 Karma Test Runner

运行此代码

0 个答案:

没有答案