【问题标题】:Test Babel transpiled(AMD) ES6 code in Karma + Jasmine在 Karma + Jasmine 中测试 Babel transpiled(AMD) ES6 代码
【发布时间】:2016-01-30 16:48:24
【问题描述】:

我在 ES6 中编写了测试,使用 Babel 将其转换为 AMD 格式的 ES5。 现在我想使用 Karma(+requirejs) 和 Jasmine 运行测试,但出现以下错误:

Error: Mismatched anonymous define() module: function (exports) {
    "use strict";

    describe("App", function () {
        it("tests something", function () {
            expect(true).toBe(true);
        });
    });
}

测试文件如下:

define(["exports"], function (exports) {
    "use strict";

    describe("App", function () {
        it("tests something", function () {
            expect(true).toBe(true);
        });
    });
});
//# sourceMappingURL=app.js.map

【问题讨论】:

    标签: jasmine karma-runner ecmascript-6


    【解决方案1】:

    我不是先转译为 ES5,而是使用 karma-babel-preprocessor。

    【讨论】: