包含Boot.js时Jasmine测试失败

时间:2016-04-27 19:24:09

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

我有大量测试,我通过Visual Studio运行,但现在我正在尝试实现测试,以便我可以使用 Karma 通过命令行运行它们。在尝试使用Karma后,我的测试开始失败,所以我认为这是Karma的错,但现在我认为它可能与 Jasmine 有关。

我认为它与Jasmine相关联,因为我开始只将我真正需要的文件包含在 karma.config.js 文件中。我删除了 jasmine / boot.js ,我的测试停止了失败。

假设我有这种格式的测试...(作为示例

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

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

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

我的第一个描述会运行,然后第二个描述,然后是 beforeEach ,然后是第一个它会发生什么等等。问题是,在我的测试成功运行后,它会再次运行 it 而不运行 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

1 个答案:

答案 0 :(得分:0)

事实证明我有一个旧版本的Jasmine和jasmine / boot.js只需要在Jasmine 2.0之后加入

相关问题