forked from Automattic/jetpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.js
More file actions
executable file
·69 lines (55 loc) · 1.62 KB
/
runner.js
File metadata and controls
executable file
·69 lines (55 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env node
require( 'babel-register' )( {
ignore: /\/node_modules\/(?!@automattic\/dops-components\/)/
} );
const program = require( 'commander' ),
glob = require( 'glob' ),
Mocha = require( 'mocha' ),
path = require( 'path' ),
boot = require( './boot-test' );
program
.usage( '[options] [files]' )
.option( '-R, --reporter <name>', 'specify the reporter to use', 'spec' )
.option( '-g, --grep <pattern>', 'only run tests matching <pattern>' );
program.name = 'runner';
program.parse( process.argv );
const mocha = new Mocha( {
ui: 'bdd',
reporter: program.reporter
} );
if ( program.grep ) {
mocha.grep( new RegExp( program.grep ) );
}
mocha.suite.beforeAll( boot.before );
mocha.suite.afterAll( boot.after );
if ( program.args.length ) {
// Test interface components
if ( 1 === program.args.length && 'gui' === program.args[0] ) {
// Don't load styles for testing
require.extensions['.scss'] = () => false;
require.extensions['.css'] = require.extensions['.scss'];
// Define a dom so we can have window and all else
require('jsdom-global')();
window.Initial_State = {
userData: {},
dismissedNotices: {}
};
mocha.addFile( '_inc/client/test/main.js' );
glob.sync( '_inc/client/**/test/component.js' ).forEach( file => {
mocha.addFile( file );
});
} else {
program.args.forEach( function( file ) {
mocha.addFile( file );
} );
}
} else {
glob.sync( '_inc/client/state/**/test/*.js' ).forEach( file => {
mocha.addFile( file );
});
}
mocha.run( function( failures ) {
process.on( 'exit', function() {
process.exit( failures ); //eslint-disable-line no-process-exit
} );
} );