0
# Command Line Interface
1
2
Testem provides a comprehensive command line interface for running tests in development and CI environments.
3
4
## Capabilities
5
6
### Development Mode
7
8
Interactive development mode with file watching and real-time test execution.
9
10
```bash { .api }
11
testem [options]
12
13
# Options:
14
# -f, --file [file] Configuration file (testem.json, testem.yml)
15
# -p, --port [num] Server port (default: 7357)
16
# --host [hostname] Host name (default: localhost)
17
# -l, --launch [list] Comma-separated list of launchers to launch
18
# -s, --skip [list] Comma-separated list of launchers to skip
19
# -d, --debug [file] Output debug to log file (default: testem.log)
20
# -t, --test_page [page] Custom HTML test page
21
# -g, --growl Enable growl/native notifications
22
```
23
24
**Usage Examples:**
25
26
```bash
27
# Basic development mode
28
testem
29
30
# With custom configuration
31
testem -f my-config.json
32
33
# Specific browsers
34
testem -l Chrome,Firefox
35
36
# Custom port and debug logging
37
testem -p 8080 -d debug.log
38
39
# Skip specific launchers
40
testem -s IE,Safari
41
```
42
43
**Interactive Controls:**
44
45
- `ENTER` - Run the tests
46
- `q` - Quit
47
- `←` / `→` - Move between browser tabs
48
- `TAB` - Switch between top/bottom panels
49
- `↑` / `↓` - Scroll up/down in text panel
50
- `SPACE` - Page down
51
- `b` - Page up
52
- `d` - Half page down
53
- `u` - Half page up
54
55
### CI Mode
56
57
Continuous integration mode for automated test execution.
58
59
```bash { .api }
60
testem ci [options]
61
62
# Additional CI options:
63
# -T, --timeout [sec] Browser timeout in seconds
64
# -P, --parallel [num] Number of parallel browsers (default: 1)
65
# -b, --bail_on_uncaught_error Exit on uncaught errors
66
# -R, --reporter [reporter] Test reporter (tap|dot|xunit|teamcity)
67
```
68
69
**Usage Examples:**
70
71
```bash
72
# Basic CI mode
73
testem ci
74
75
# Parallel execution
76
testem ci -P 5
77
78
# Custom reporter
79
testem ci -R xunit
80
81
# With timeout and bail on error
82
testem ci -T 60 -b
83
84
# Combined options
85
testem ci -P 3 -R tap -T 30
86
```
87
88
### Server Mode
89
90
Server-only mode for manual testing without automatic browser launching.
91
92
```bash { .api }
93
testem server [options]
94
95
# Uses same options as development mode but doesn't auto-launch browsers
96
```
97
98
**Usage Examples:**
99
100
```bash
101
# Start server only
102
testem server
103
104
# Custom port
105
testem server -p 9000
106
107
# With configuration file
108
testem server -f server-config.json
109
```
110
111
### Launchers Command
112
113
List available browser and process launchers on the system.
114
115
```bash { .api }
116
testem launchers
117
```
118
119
**Example Output:**
120
121
```
122
Have 7 launchers available; auto-launch info displayed on the right.
123
124
Launcher Type CI Dev
125
------------ ------------ -- ---
126
Chrome browser ✔
127
Firefox browser ✔
128
Safari browser ✔
129
IE browser ✔
130
Node process ✔
131
PhantomJS browser ✔
132
Mocha process(TAP) ✔
133
```
134
135
### Help Commands
136
137
Get help information for testem commands.
138
139
```bash { .api }
140
testem --help # General help
141
testem ci --help # CI mode help
142
```
143
144
## Global Options
145
146
Options available across all testem commands:
147
148
```bash { .api }
149
# Configuration
150
-f, --file [file] # Configuration file path
151
-p, --port [num] # Server port number
152
--host [hostname] # Server hostname
153
154
# Browser Control
155
-l, --launch [list] # Launchers to start (comma-separated)
156
-s, --skip [list] # Launchers to skip (comma-separated)
157
158
# Output & Debugging
159
-d, --debug [file] # Debug output file
160
-g, --growl # Native notifications
161
-t, --test_page [page] # Custom test page
162
163
# CI-Specific
164
-T, --timeout [sec] # Browser timeout
165
-P, --parallel [num] # Parallel browsers
166
-b, --bail_on_uncaught_error # Exit on errors
167
-R, --reporter [reporter] # Test reporter format
168
```
169
170
## Exit Codes
171
172
Testem uses standard exit codes to indicate test results:
173
174
```bash { .api }
175
0 # All tests passed
176
1 # Tests failed or error occurred
177
```
178
179
## Environment Variables
180
181
Environment variables that affect testem behavior:
182
183
```bash { .api }
184
PORT # Default port (overridden by --port)
185
TESTEM_CONFIG # Configuration file path
186
NODE_ENV # Environment mode (affects default settings)
187
```
188
189
## Configuration File Discovery
190
191
Testem automatically searches for configuration files in this order:
192
193
```bash { .api }
194
testem.json # JSON configuration (highest priority)
195
.testem.json # Hidden JSON configuration
196
.testem.yml # Hidden YAML configuration
197
testem.yml # YAML configuration
198
testem.js # JavaScript configuration
199
.testem.js # Hidden JavaScript configuration
200
testem.cjs # CommonJS configuration
201
.testem.cjs # Hidden CommonJS configuration (lowest priority)
202
```
203
204
If multiple files exist, testem uses the first one found and warns about duplicates.