forked from testem/testem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testem.js
executable file
·67 lines (56 loc) · 1.83 KB
/
testem.js
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
#!/usr/bin/env node
var log = require('winston')
var program = require('commander')
var progOptions = program
var Config = require('./lib/config')
var catchem = require('./lib/catchem')
var appMode = 'dev'
program
.version(require(__dirname + '/package').version)
.usage('[options]')
.option('-f, --file [file]', 'config file - defaults to testem.json or testem.yml')
.option('-p, --port [num]', 'server port - defaults to 7357', Number)
.option('-l, --launch [list]', 'list of launchers to launch(comma separated)')
.option('-s, --skip [list]', 'list of launchers to skip(comma separated)')
.option('-d, --debug', 'output debug to debug log - testem.log')
.option('-t, --test_page [page]', 'the html page to drive the tests')
program
.command('launchers')
.description('Print the list of available launchers (browsers & process launchers)')
.action(function(env){
env.__proto__ = program
progOptions = env
appMode = 'launchers'
})
program
.command('ci')
.description('Continuous integration mode')
.option('-t, --timeout [sec]', 'timeout a browser after [sec] seconds', null)
.action(function(env){
env.__proto__ = program
progOptions = env
appMode = 'ci'
})
program.parse(process.argv)
log.remove(log.transports.Console)
if (progOptions.debug){
log.add(log.transports.File, {filename: 'testem.log'})
}
log.info("Test'em starting...")
catchem.on('err', function(e){
log.error(e.message)
log.error(e.stack)
})
var config = new Config(appMode, progOptions)
if (appMode === 'launchers'){
config.read(function(){
config.printLauncherInfo()
})
}else{
App = appMode === 'ci' ?
require('./lib/ci_mode_app') :
require('./lib/dev_mode_app')
config.read(function(){
new App(config)
})
}