testing - Yeoman webapp generator - How to run mocha tests in the Browser -
i've got js tests written in mocha/chai , run them in project scaffolded using webapp generator.
i've put tests inside "test" folder yeoman's structure , tests running fine. issue grunt test command showing test results in console, not in browser.
i'm looking way run command , have tests shown in browser. how can that?
thanks help!
please consider part of connect's configuration (more precisely, sub-task of connect):
test : { options : { middleware : function(connect) { return [ require('connect-livereload')(), mountfolder(connect, '.tmp'), mountfolder(connect, 'test') ]; }, port : grunt.option('port') ? number(grunt.option('port')) + 1 : 9001 } } the above make files specified folders available through http.
.tmptranspiled coffeescript , scss landing regular js/csstesttests reside simpleindex.htmlfile wires js/css together, includingmocha.js,mocha.css
later in gruntfile register test task:
grunt.registertask('test', function(target) { var tasks = [ 'clean:server', 'coffee', 'jst', 'connect:test' ]; if (target === 'browser') { tasks.push('open:test'); tasks.push('watch'); } else { tasks.push('mocha'); } grunt.task.run(tasks); }); the part relevant problem 'connect:test' makes possible access tests through browser, , one:
if (target === 'browser') { tasks.push('open:test'); tasks.push('watch'); } else { tasks.push('mocha'); } as long don't specify browser test target, tests run headlessly in console. if go grunt test:browser, grunt open browser open:test. reference, include open:test config:
test : { path : 'http://localhost:<%= connect.test.options.port %>' }
Comments
Post a Comment