0
# CLI Usage
1
2
Comprehensive command-line interface for running jasmine-node tests with extensive configuration options for test execution, file watching, output formatting, and CI integration.
3
4
## Capabilities
5
6
### Basic Test Execution
7
8
Run tests from the command line with basic options.
9
10
```bash { .api }
11
# Basic usage
12
jasmine-node [options] [spec_directories...] [spec_files...]
13
14
# Examples
15
jasmine-node spec/
16
jasmine-node spec/ test/unit/
17
jasmine-node spec/userSpec.js spec/authSpec.js
18
```
19
20
**Usage Examples:**
21
22
```bash
23
# Display version information
24
jasmine-node --version
25
26
# Run all specs in spec directory
27
jasmine-node spec/
28
29
# Run specific spec files
30
jasmine-node spec/userSpec.js spec/authSpec.js
31
32
# Run specs in multiple directories
33
jasmine-node spec/ test/unit/ test/integration/
34
```
35
36
### File Watching and Auto-Testing
37
38
Automatically re-run tests when files change during development.
39
40
```bash { .api }
41
# Auto-testing options
42
--autotest # Automatic execution of specs after each change
43
--watch [paths...] # Additional paths to watch for changes (used with --autotest)
44
```
45
46
**Usage Examples:**
47
48
```bash
49
# Auto-run tests when spec files change
50
jasmine-node --autotest spec/
51
52
# Watch additional directories for changes
53
jasmine-node --autotest --watch lib/ --watch src/ spec/
54
55
# Watch specific files
56
jasmine-node --autotest --watch config.js --watch package.json spec/
57
```
58
59
### Output Formatting
60
61
Control test output appearance and verbosity.
62
63
```bash { .api }
64
# Output formatting options
65
--color # Use colored output (green for pass, red for fail)
66
--noColor # Disable colored output
67
--verbose # Verbose output showing individual test progress
68
--noStack # Suppress stack traces on test failures
69
```
70
71
**Usage Examples:**
72
73
```bash
74
# Colorized output
75
jasmine-node --color spec/
76
77
# Verbose output with detailed progress
78
jasmine-node --verbose spec/
79
80
# Clean output without stack traces
81
jasmine-node --noColor --noStack spec/
82
83
# Force color output even when piping
84
jasmine-node --color spec/ | tee test-results.log
85
```
86
87
### Test File Filtering
88
89
Filter which test files are executed based on patterns and matching rules.
90
91
```bash { .api }
92
# File filtering options
93
-m, --match REGEXP # Only run specs containing "REGEXPspec" in filename
94
--matchall # Relax requirement of "spec" in spec file names
95
```
96
97
**Usage Examples:**
98
99
```bash
100
# Only run user-related tests
101
jasmine-node --match user spec/
102
103
# Run tests matching specific pattern
104
jasmine-node --match "integration|e2e" spec/
105
106
# Allow files without "spec" in name (must still end with .js/.coffee/.litcoffee)
107
jasmine-node --matchall test/
108
```
109
110
### Language Support
111
112
Support for CoffeeScript and Literate CoffeeScript test files.
113
114
```bash { .api }
115
# Language support options
116
--coffee # Enable CoffeeScript support (.coffee and .litcoffee files)
117
```
118
119
**Usage Examples:**
120
121
```bash
122
# Run CoffeeScript specs
123
jasmine-node --coffee spec/
124
125
# Mixed JavaScript and CoffeeScript
126
jasmine-node --coffee spec/ # Will run .js, .coffee, and .litcoffee files
127
```
128
129
### Reporting and Output
130
131
Generate reports in various formats for different environments and CI systems.
132
133
```bash { .api }
134
# Reporting options
135
--junitreport # Export test results as JUnit XML format
136
--output FOLDER # Output folder for JUnit XML reports (default: ./reports/)
137
--teamcity # Convert output to TeamCity test runner format
138
--growl # Display test summary in Growl notifications
139
```
140
141
**Usage Examples:**
142
143
```bash
144
# Generate JUnit XML reports
145
jasmine-node --junitreport spec/
146
147
# Custom output directory for reports
148
jasmine-node --junitreport --output ./test-reports/ spec/
149
150
# TeamCity integration
151
jasmine-node --teamcity spec/
152
153
# Desktop notifications (requires Growl)
154
jasmine-node --growl spec/
155
156
# Combined reporting
157
jasmine-node --junitreport --growl --output ./reports/ spec/
158
```
159
160
### RequireJS Support
161
162
Integration with RequireJS for AMD module loading.
163
164
```bash { .api }
165
# RequireJS options
166
--runWithRequireJs # Load all specs using RequireJS instead of Node's require
167
--requireJsSetup FILE # Configuration file for RequireJS setup
168
```
169
170
**Usage Examples:**
171
172
```bash
173
# Use RequireJS for spec loading
174
jasmine-node --runWithRequireJs spec/
175
176
# Custom RequireJS configuration
177
jasmine-node --runWithRequireJs --requireJsSetup ./config/requirejs-test-config.js spec/
178
```
179
180
### Test Environment Configuration
181
182
Configure test execution environment and behavior.
183
184
```bash { .api }
185
# Environment options
186
--test-dir PATH # Absolute root directory path where tests are located
187
--nohelpers # Skip loading helper files
188
--forceexit # Force exit once tests complete
189
--captureExceptions # Capture and report global exceptions
190
--config NAME VALUE # Set environment variable for tests
191
```
192
193
**Usage Examples:**
194
195
```bash
196
# Set custom test directory
197
jasmine-node --test-dir /absolute/path/to/tests spec/
198
199
# Skip helper files
200
jasmine-node --nohelpers spec/
201
202
# Force exit (useful in CI environments)
203
jasmine-node --forceexit spec/
204
205
# Capture uncaught exceptions
206
jasmine-node --captureExceptions spec/
207
208
# Set environment variables
209
jasmine-node --config NODE_ENV test --config API_URL http://localhost:3000 spec/
210
211
# Multiple environment variables
212
jasmine-node --config DB_HOST localhost --config DB_PORT 5432 --config LOG_LEVEL debug spec/
213
```
214
215
### Complete CLI Options Reference
216
217
```bash { .api }
218
# All available command-line options
219
jasmine-node [options] [paths...]
220
221
Options:
222
--version Display version information
223
--autotest Automatic execution after file changes
224
--watch [paths...] Watch additional paths for changes (with --autotest)
225
--coffee Execute .coffee and .litcoffee specs
226
--color Use colored output
227
--noColor Disable colored output
228
-m, --match REGEXP Match only specs containing "REGEXPspec"
229
--matchall Relax "spec" requirement in filenames
230
--verbose Verbose output during execution
231
--junitreport Export JUnit XML reports
232
--output FOLDER Output folder for JUnit reports
233
--teamcity TeamCity reporter format
234
--growl Growl notification summaries
235
--runWithRequireJs Use RequireJS for spec loading
236
--requireJsSetup FILE RequireJS configuration file
237
--test-dir PATH Absolute root test directory
238
--nohelpers Skip loading helper files
239
--forceexit Force exit after completion
240
--captureExceptions Capture global exceptions
241
--config NAME VALUE Set environment variables
242
--noStack Suppress stack traces on failures
243
```
244
245
## Configuration Examples
246
247
### Development Workflow
248
249
```bash
250
# Development with auto-testing and notifications
251
jasmine-node --autotest --watch lib/ --watch src/ --color --growl spec/
252
```
253
254
### Continuous Integration
255
256
```bash
257
# CI environment with XML reports and exception handling
258
jasmine-node --junitreport --output ./test-reports/ --captureExceptions --forceexit --noColor spec/
259
```
260
261
### TeamCity Integration
262
263
```bash
264
# TeamCity-specific reporting
265
jasmine-node --teamcity --captureExceptions --forceexit spec/
266
```
267
268
### Complex Project Setup
269
270
```bash
271
# Large project with multiple languages and custom configuration
272
jasmine-node \
273
--coffee \
274
--runWithRequireJs \
275
--requireJsSetup ./test/requirejs-config.js \
276
--match "unit|integration" \
277
--verbose \
278
--junitreport \
279
--output ./reports/ \
280
--config NODE_ENV test \
281
--config API_BASE_URL http://localhost:3000 \
282
spec/unit/ spec/integration/
283
```
284
285
## File Pattern Requirements
286
287
jasmine-node automatically discovers test files based on naming patterns:
288
289
- **JavaScript files**: Must match `/spec\.(js)$/i` pattern (e.g., `userSpec.js`, `authenticationSpec.js`)
290
- **CoffeeScript files**: Must match `/spec\.(coffee|litcoffee)$/i` pattern (e.g., `userSpec.coffee`, `docsSpec.litcoffee`)
291
- **Helper files**: Any `.js` files in helper directories (loaded before specs)
292
293
Invalid examples: `sampleSpecs.js`, `testUser.js`, `user-test.js`
294
Valid examples: `sampleSpec.js`, `userSpec.js`, `authSpec.coffee`