2013-01-13 19 views
8

Ho creato Grunt.js e ho scritto i miei test che voglio testare usando mocha-phantomjs.Uso di Grunt.js per eseguire i test della moka

ho solo bisogno di aiuto per scrivere un compito che verrà eseguito

$ mocha-phantomjs ./tests/index.html 

Dopo un po 'guardando in giro ho visto che non v'è un compito grugnito per l'esecuzione di comandi di shell, ma non c'è un modo più semplice?

Sono nuovo per grugnire. Ho visto che riconosce il comando grunt qunit. È integrato? Non può esserci qualcosa del genere per la moka? Devo richiedere child_process ed eseguirlo?

Update: utilizzando child_process ed eseguendo il comando non aspettare il risultato finale

risposta

12

È possibile registrare test ad un processo figlio (come Yeoman sta facendo con Testacular):

// Alias the `test` task to run `mocha-phantomjs` instead 
    grunt.registerTask('test', 'run mocha-phantomjs', function() { 
    var done = this.async(); 
    require('child_process').exec('mocha-phantomjs ./tests/index.html', function (err, stdout) { 
     grunt.log.write(stdout); 
     done(err); 
    }); 
    }); 

Nel Terminale quindi eseguire semplicemente grunt test per eseguire i test.

10

So che questo è vecchio, ma esiste un'attività grunt-mocha che esegue test di mocha in phantomjs.

Problemi correlati