Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var Mocha = require( 'mocha' ), | ||
mocha = new Mocha, | ||
fs = require( 'fs' ), | ||
path = require( 'path' ); | ||
|
||
module.exports = { | ||
// Run the test using mocha on a pie | ||
test: function( pie ) { | ||
// Get all the test files of this pie | ||
var files = fs.readdirSync( | ||
path.join( process.cwd(), 'pies', pie.path, 'test' ) | ||
|
||
).filter( function( file ) { | ||
// Keep only the .js files | ||
return file.substr( -3 ) === '.js'; | ||
|
||
}).forEach( function( file ) { | ||
// Add each file to mocha | ||
mocha.addFile( | ||
path.join( | ||
process.cwd(), | ||
'pies', | ||
pie.path, | ||
'test', | ||
file | ||
) | ||
); | ||
}); | ||
|
||
// If there is no file to test in this pie, just return | ||
if ( mocha.files.length === 0 ) { | ||
return; | ||
} | ||
|
||
// Get the pie name by splitting the path | ||
var pieName = pie.path.split( '/' ).reverse()[ 0 ]; | ||
|
||
console.log( '\nRunning tests for ' + pieName ); | ||
|
||
// And run mocha tests while setting the reporter to "list" | ||
mocha.reporter( 'list' ).run(); | ||
} | ||
}; | ||
|