0
# Command Line Interface
1
2
The Web Component Tester command line interface provides the primary way to run tests from the terminal, with support for various browsers, configuration options, and CI/CD integration.
3
4
## Capabilities
5
6
### Main CLI Command
7
8
The primary entry point for running tests via the `wct` command.
9
10
```typescript { .api }
11
/**
12
* Main CLI entry point function that parses command line arguments and runs tests
13
* @param env - Environment variables object
14
* @param args - Command line arguments array
15
* @param output - Output stream for writing results
16
* @returns Promise that resolves when tests complete
17
*/
18
function run(env: any, args: string[], output: NodeJS.WritableStream): Promise<void>;
19
```
20
21
**Usage Examples:**
22
23
```bash
24
# Run all tests in test/ directory
25
wct
26
27
# Run specific test files
28
wct test/my-test.html test/other-test.js
29
30
# Run with verbose output
31
wct --verbose
32
33
# Run with specific browsers
34
wct --local chrome --local firefox
35
36
# Run on Sauce Labs
37
wct --sauce
38
39
# Skip cleanup (useful for debugging)
40
wct --skip-cleanup
41
42
# Use custom configuration file
43
wct --config-file custom-wct.conf.json
44
```
45
46
### Sauce Labs Tunnel Command
47
48
Manages Sauce Labs tunnel for remote testing via the `wct-st` command.
49
50
```typescript { .api }
51
/**
52
* Sauce Labs tunnel runner for establishing secure connection to Sauce Labs
53
* @param env - Environment variables object
54
* @param args - Command line arguments array
55
* @param output - Output stream for writing results
56
* @returns Promise that resolves when tunnel is established
57
*/
58
function runSauceTunnel(env: any, args: string[], output: NodeJS.WritableStream): Promise<void>;
59
```
60
61
**Usage Examples:**
62
63
```bash
64
# Start Sauce Labs tunnel
65
wct-st --username your-username --access-key your-key
66
67
# Start tunnel with specific tunnel identifier
68
wct-st --tunnel-id my-tunnel-123
69
70
# Start tunnel for specific browsers
71
wct-st --browsers chrome,firefox
72
```
73
74
## Command Line Options
75
76
### General Options
77
78
```bash
79
--version, -V # Show version number
80
--help, -h # Show help information
81
--verbose # Enable verbose logging
82
--quiet # Suppress output
83
--simpleOutput # Use simple output format
84
--skipUpdateCheck # Skip checking for updates
85
```
86
87
### Test Configuration
88
89
```bash
90
--root <path> # Root directory for tests (default: current directory)
91
--suites <patterns> # Test file patterns to run
92
--timeout <ms> # Test timeout in milliseconds
93
--persistent # Keep browsers open after tests
94
--expanded # Show expanded test results
95
```
96
97
### Browser Options
98
99
```bash
100
--local <browser> # Run tests on local browser (chrome, firefox, safari, etc.)
101
--sauce # Run tests on Sauce Labs
102
--browsers <list> # Comma-separated list of browsers
103
--skip-selenium-install # Skip automatic Selenium installation
104
```
105
106
### Plugin Options
107
108
```bash
109
--plugin <name> # Load specific plugin
110
--skip-plugin <name> # Skip loading specific plugin
111
```
112
113
### Configuration Files
114
115
```bash
116
--config-file <path> # Path to custom configuration file
117
```
118
119
## Environment Variables
120
121
### Sauce Labs Configuration
122
123
```bash
124
SAUCE_USERNAME # Sauce Labs username
125
SAUCE_ACCESS_KEY # Sauce Labs access key
126
SAUCE_TUNNEL_ID # Existing tunnel ID to use
127
```
128
129
### General Configuration
130
131
```bash
132
CI # Set to disable TTY output in CI environments
133
WCT_PACKAGE_NAME # Override package name for client-side code
134
```
135
136
## Configuration File Format
137
138
The CLI supports configuration via `wct.conf.json` files:
139
140
```json
141
{
142
"verbose": true,
143
"root": "./",
144
"suites": ["test/**/*.html", "test/**/*.js"],
145
"plugins": {
146
"local": {
147
"browsers": ["chrome", "firefox"]
148
},
149
"sauce": {
150
"username": "your-username",
151
"accessKey": "your-key",
152
"browsers": [{
153
"browserName": "chrome",
154
"platform": "Windows 10"
155
}]
156
}
157
},
158
"clientOptions": {
159
"verbose": false,
160
"environmentScripts": []
161
}
162
}
163
```
164
165
## Exit Codes
166
167
```bash
168
0 # Success - all tests passed
169
1 # Failure - tests failed or error occurred
170
```
171
172
## Integration Examples
173
174
### CI/CD Pipeline
175
176
```yaml
177
# .github/workflows/test.yml
178
name: Test
179
on: [push, pull_request]
180
jobs:
181
test:
182
runs-on: ubuntu-latest
183
steps:
184
- uses: actions/checkout@v2
185
- uses: actions/setup-node@v2
186
- run: npm install
187
- run: wct --local chrome --local firefox
188
```
189
190
### NPM Scripts
191
192
```json
193
{
194
"scripts": {
195
"test": "wct",
196
"test:chrome": "wct --local chrome",
197
"test:sauce": "wct --sauce",
198
"test:debug": "wct --persistent --verbose"
199
}
200
}
201
```