Bundle test files into a single file using browserify.
var bundle = require( '@stdlib/_tools/tests/bundle' );Given a root directory from which to search for tests, bundle tests into a single file using browserify.
var cwd = require( '@stdlib/process/cwd' );
bundle( cwd(), clbk );
function clbk( error, bundle ) {
if ( error ) {
throw error;
}
console.log( bundle.toString() );
}The function accepts the following options:
- out: output file path.
- pattern: glob pattern. Default:
'**/test*.js'.
To specify an output file path, set the out option.
var cwd = require( '@stdlib/process/cwd' );
var opts = {
'out': '/foo/bar/bundle.js'
};
bundle( cwd(), opts, clbk );
function clbk( error, bool ) {
if ( error ) {
throw error;
}
if ( bool ) {
console.log( 'Success!' );
} else {
console.log( 'No bundle generated.' );
}
}To provide an alternative glob pattern, set the pattern option.
var cwd = require( '@stdlib/process/cwd' );
var opts = {
'pattern': '**/t.js'
};
bundle( cwd(), opts, clbk );
function clbk( error, bundle ) {
if ( error ) {
throw error;
}
console.log( bundle.toString() );
}var join = require( 'path' ).join;
var bundle = require( '@stdlib/_tools/tests/bundle' );
var root = join( __dirname, 'fixtures' );
var opts = {
'pattern': '*.js'
};
bundle( root, opts, onBundle );
function onBundle( error, bundle ) {
if ( error ) {
throw error;
}
console.log( bundle.toString() );
}Usage: test-bundle [options] [<dir>]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--pattern glob Glob pattern.- If not provided a root directory, the root directory is the current working directory.
$ test-bundle --pattern 'index.js' ./examples/fixtures