日期:2014-05-16 浏览次数:20718 次
npm install -g karma karma-cli npm install -g karma-jasmine karma-chrome-launcher karma-firefox-launcher karma-ie-launcher karma-junit-reporter karma-commonjs karma-coverage
module.exports = function(config) { config.set({ basePath: '../', files: [ 'public_html/js/*.js', 'test/js/*.js' ], exclude: [ ], autoWatch: true, frameworks: ['jasmine' ], browsers: ['Chrome' ], reporters: ['progress', 'junit'], // the default configuration junitReporter: { outputFile: 'test-results.xml', suite: '' }, plugins: [ 'karma-junit-reporter', 'karma-chrome-launcher', 'karma-firefox-launcher', 'karma-script-launcher', 'karma-jasmine' ] }); };
//路径public_html/js/plus.js // Some code under test function plus(a, b) { return a + b; }
//路径test/js/test.js describe('plus', function() { it('should pass', function() { expect(true).toBe(true); }); it('should work', function() { expect(plus(1, 2)).toBe(3); }); it('should work', function() { expect(plus(5, 4)).toBe(2); }); });
ERROR [karma]: [TypeError: Cannot call method 'push' of undefined] TypeError: Cannot call method 'push' of undefined at onBrowserStart (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\lib\reporters\base.js:14:20) at null.<anonymous> (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\lib\events.js:15:22) at EventEmitter.emit (events.js:117:20) at onStart (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\lib\browser.js:128:13) at Socket.<anonymous> (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\lib\events.js:15:22) at Socket.EventEmitter.emit [as $emit] (events.js:117:20) at SocketNamespace.handlePacket (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\node_modules\socket.io\lib\namespace.js:335:22) at Manager.onClientMessage (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\node_modules\socket.io\lib\manager.js:488:38) at WebSocket.Transport.onMessage (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\node_modules\socket.io\lib\transport.js:387:20) at Parser.<anonymous> (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\node_modules\socket.io\lib\transports\websocket\hybi-16.js:39:10) 完成。
Product Version: NetBeans IDE 8.0 (Build 201403101706) 更新: NetBeans IDE 已更新到版本 NetBeans 8.0 Patch 1.1 Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08 Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18 System: Windows 7 version 6.1 running on amd64; GBK; zh_CN (nb) C:\Users>node --version v0.10.22 C:\Users>karma --version Karma version: 0.12.9
start "D:\Program Files\NetBeans 8.0\webcommon\karma\karma-netbeans.conf.js" --port 9880