[英]Jasmine test case in maven with requirejs
我想使用茉莉進行單元測試javascript應用程序。 我的應用程序使用requirejs。 我找到了Jasmine Maven插件
該插件非常適合非requirejs應用程序。 它還具有requirejs模板,但是我無法使用Maven成功運行測試用例。
我已經寫了示例測試用例
require(['models/MyModel'], function(GlobalSettingsModel) { //this code doesn't execute describe('Test description', function() { it('some test', function(done) { expect(1 + 2).toBe(4); //it doesn't throw error }); }); }); describe('Test description new', function() { require(['models/MyModel'], function(GlobalSettingsModel) { it('some test', function(done) { expect(1 + 2).toBe(4); //it doesn't throw error }); }); }); describe('Test description new', function() { it('some test', function(done) { expect(1 + 2).toBe(4); //it throw error }); });
如果我將測試用例包裝在requirejs中,那么maven將不會在requirejs塊中執行代碼。 如果我在requirejs(第一行)中給出了不存在的js文件,則拋出該文件不存在的錯誤。
我嘗試了多種方法將jasmine(requirejs)與maven集成在一起,但是找不到任何其他插件或任何解決方案。
而不是將describe方法包裝在require塊中,我需要將describe包裝在define塊中
define(['model'], function(Model) { describe('Test description new', function() { it('some test', function(done) { expect(1 + 2).toBe(4); //it throw error }); }); });
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.