2016-04-14 16 views
5

Ho usato Karma circa 1 anno fa e tutto ha funzionato bene. Quando ho modificato i test e salvato il file .test.js, il test è stato eseguito automaticamente: non è stato necessario riavviare o modificare nulla. Oggi volevo eseguire nuovamente questi test. Avere un nuovo computer, ho dovuto installare nodo e NPM e quant'altro, e poi ho installato anche:L'orologio automatico Karma non funziona

npm install -g karma karma-cli karma-jasmine karma-chrome-launcher

Ho configurato Karma come segue (karma init):

// Karma configuration 
// Generated on Thu Apr 14 2016 14:50:35 GMT+0200 (Central Europe Summer Time) 

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: [ 
     'js/*.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: ['Chrome'], 


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

    // Concurrency level 
    // how many browser should be started simultaneous 
    concurrency: Infinity 
    }) 
} 

Quando inizio il karma (karma start karma.conf.js) una nuova scheda di Chrome aperta, con la porta, specificata nel file di configurazione. Il test è stato eseguito, tutto ha funzionato come previsto. Tuttavia, quando ho modificato qualcosa nel file .test.js, Karma non eseguiva l'esecuzione automatica. In realtà, non sono state apportate modifiche. Ho dovuto riavviare Karma in CMD e ho ripreso a correre per vedere i nuovi risultati.

Tuttavia, se apro una nuova CMD ed eseguo karma run, il test viene aggiornato. Quindi, la parte che controlla le modifiche non funziona, ovviamente.

Quindi, non ho idea di cosa mi manca qui, ma la funzione di orologio automatico di Karma non funziona più. Qualche suggerimento dove dovrei iniziare?

+1

Sei mai stato in grado di risolvere questo? Se è così, per favore pubblica la tua risposta. – Chic

risposta

3

Ho finalmente trovato la soluzione dopo mesi di ricerche.

Sono sicuro che ci sono altri modi per disabilitare la cache in chrome. Ma questo ha funzionato per me subito.

Dopo aver digitato karma start, e lanci di cromo, attivare strumenti di sviluppo, e nella scheda di rete, controllare disable cache

Problemi correlati