2015-10-07 11 views
6

test yineleniyor zamanlarda miktarı testler ve çalışma için kullanılan tarayıcılar sayısına bağlı görünmektedir sonuçlanır. sadece bir tarayıcı kullanarak (PhantomJS veya Chrome) bir test için test iki kez gösterilirse tarayıcılarının kullanırkenKarma çıkış çoğaltma testi karması son testi birden çok kez çoğaltarak gibi görünüyor testleri çalıştırırken

, aynı tek bir test 6 kata kadar gösterilir. Testten içine günlüğü ekledik

, günlük yüzden muhtemelen testler kez doğru sayıda çalışan ama sadece sonuç gösterilmektedir çoğaltarak, bir kez Tarayıcı başına test başına oluşur.

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'); 
    }); 
}); 

Çıkış 1 Tarayıcı (Krom)

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) 

Çıkış 2 Browser (PhantomJS, krom)

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 

Bunu karma-cli yüklü ve karma olmadan test ettim ve sonuçlar aynı. Ben yığın taşması ve google ve birkaç kişi etrafında baktım

benzer sorunlar karşılaşmış gibi ama anlamlı bir cevabı yoktur.

+0

Bunu anlatan bir şans var mı? Aynı sorunu yaşıyoruz. –

+0

Maalesef, şu an bununla yaşıyorum, aynı konfigürasyonu çalıştırıyor musunuz? – ndonohoe

cevap

0

Çalışan bir çalışma yapmaya çalışırken benzer sorunlar yaşadım. Sağ -

karma.conf autoWatch, tarayıcılar, singleRun gibi çeşitli seçenekler alır? Bunların arasında müşteri denilen bir özellik var.

İstemci özelliği, kendi kendine ait birkaç özelliğe sahip bir nesnedir. Amacı, örneğin Chrome gibi test istemcisi ile ilgili ayarları yapılandırmaktır.

istemcinin captureConsole adlı bir özelliği vardır. Bu varsayılan olarak doğrudur, yani tarayıcıda oturum açan herhangi bir konsol da bash'ınıza geri gönderilir. Bu nedenle, varsayılan olarak, hem Chrome'un konsol günlüğü hem de güzelleştirilmiş çıktı çıktılarını görüyordum.

Bu ayarı kendi başınıza deneyin ve yardımcı olup olmadığını görün!

0

Bunun yıllar önce sorulduğunu, ancak windows komut satırından karma çalıştırmanın herhangi bir şans olduğunu biliyorum. Aynı sorunu yaşadım, birkaç saatliğine googledim, ve sonra bir kapriste powershell'den koştum ve iyi çalıştı. Ayrıca git bash ile çalıştı.