2015-10-07 149 views
6

当运行测试因缘好像最后一次测试多次被重复,次的试验是重复的量似乎取决于试验和用于运行浏览器的数量。噶输出复制测试结果

如果仅使用一个浏览器(PhantomJS或铬)用于一个测试,测试中示出了两次,同时使用浏览器时相同的单个测试示出多达6次。

我已经添加日志到测试,日志出现每浏览器测试一次,所以想必测试正在运行的正确的次数,但只复制中所示的结果。

karma.conf.js

module.exports = function(config) { 
    config.set({ 

    // base path that will be used to resolve all patterns (eg. files, exclude) 
    basePath: '', 


    // frameworks to use 
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 
    frameworks: ['jasmine'], 


    // list of files/patterns to load in the browser 
    files: [ 
     '_test/test.js' 
    ], 


    // list of files to exclude 
    exclude: [ 
    ], 


    // preprocess matching files before serving them to the browser 
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 
    preprocessors: { 
    }, 


    // test results reporter to use 
    // possible values: 'dots', 'progress' 
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter 
    reporters: ['progress'], 


    // web server port 
    port: 9876, 


    // enable/disable colors in the output (reporters and logs) 
    colors: true, 


    // level of logging 
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 
    logLevel: config.LOG_INFO, 


    // enable/disable watching file and executing tests whenever any file changes 
    autoWatch: true, 


    // start these browsers 
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 
    browsers: ['PhantomJS', 'Chrome'], 


    // Continuous Integration mode 
    // if true, Karma captures browsers, runs the tests and exits 
    singleRun: false 
    }) 
} 

test.js

describe('karma testing', function() { 
    it('tests karma is working', function() { 
     expect(true).toBe(true); 
     console.log('test1'); 
    }); 
}); 

输出1个浏览器(Chrome)

07 10 2015 16:41:14.890:INFO [karma]: Karma v0.13.10 server started at http://localhost:9876/ 
07 10 2015 16:41:14.897:INFO [launcher]: Starting browser Chrome 
07 10 2015 16:41:16.364:INFO [Chrome 45.0.2454 (Windows 7 0.0.0)]: Connected on socket 0uvPocfSI0prGxwdAAAA with id 29520633 
LOG: 'test1' 
Chrome 45.0.2454 (Windows 7 0.0.0): Executed 1 of 1 SUCCESS (0 secs/0.003 secs 
Chrome 45.0.2454 (Windows 7 0.0.0): Executed 1 of 1 SUCCESS (0.011 secs/0.003 secs) 

输出2的浏览器(PhantomJS,铬)

07 10 2015 16:27:31.399:INFO [karma]: Karma v0.13.10 server started at http://localhost:9876/ 
07 10 2015 16:27:31.407:INFO [launcher]: Starting browser PhantomJS 
07 10 2015 16:27:31.420:INFO [launcher]: Starting browser Chrome 
07 10 2015 16:27:32.886:INFO [PhantomJS 1.9.8 (Windows 7 0.0.0)]: Connected on socket P5focoe7004aPX1rAAAA with id 49258591 
07 10 2015 16:27:33.077:INFO [Chrome 45.0.2454 (Windows 7 0.0.0)]: Connected on socket BGtRdqevRGGXZTA-AAAB with id 42323971 
LOG: 'test1' 
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 1 of 1 SUCCESS (0 secs/0.003 secs) 
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 1 of 1 SUCCESS (0.007 secs/0.003 s 
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 1 of 1 SUCCESS (0.007 secs/0.003 s 
Chrome 45.0.2454 (Windows 7 0.0.0) LOG: 'test1' 
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 1 of 1 SUCCESS (0.007 secs/0.003 s 
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 1 of 1 SUCCESS (0.007 secs/0.003 secs) 
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 1 of 1 SUCCESS (0.007 secs/0.003 secs) 
Chrome 45.0.2454 (Windows 7 0.0.0): Executed 1 of 1 SUCCESS (0.028 secs/0.002 secs) 
TOTAL: 2 SUCCESS 

我已经测试过,没有安装karma-cli,结果是一样的。

我身边有栈溢出和谷歌的几个人看着似乎已经遇到过类似的问题,但目前还没有意义的答案。

+0

任何运气找出这一个?我们遇到同样的问题。 –

+0

不幸的是,我现在刚刚一直在用它,你是否运行相同的配置? – ndonohoe

回答

0

我试图让prettifier工作时,也有类似的问题。

karma.conf需要几个选项,比如autoWatch,浏览器,singleRun - 对不对?所有这些都是一个叫做客户端的属性。

客户端属性是一个具有自己的几个属性的对象。其目的是配置与测试客户端相关的设置,例如Chrome。

客户端有一个名为captureConsole的属性。这默认为true,这意味着浏览器中的任何控制台日志记录都会发送回您的bash。所以,默认情况下打开了,我看到了Chrome的控制台日志记录和美化的tap输出。

尝试在您的设置,看看它是否有帮助!

client: { 
    captureConsole: false 
}, 
0

我知道这是几年前问过的,但是有没有机会从Windows命令行运行业务?我有同样的问题,浪费了几个小时的搜索引擎优化,然后在一个奇思妙想从PowerShell中运行它,它运行良好。也使用git bash。