A comprehensive testing framework specifically designed for web components with browser-based testing environment, Mocha/Chai/Sinon integration, and support for both local and remote testing via Sauce Labs.
—
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.
The primary entry point for running tests via the wct command.
/**
* Main CLI entry point function that parses command line arguments and runs tests
* @param env - Environment variables object
* @param args - Command line arguments array
* @param output - Output stream for writing results
* @returns Promise that resolves when tests complete
*/
function run(env: any, args: string[], output: NodeJS.WritableStream): Promise<void>;Usage Examples:
# Run all tests in test/ directory
wct
# Run specific test files
wct test/my-test.html test/other-test.js
# Run with verbose output
wct --verbose
# Run with specific browsers
wct --local chrome --local firefox
# Run on Sauce Labs
wct --sauce
# Skip cleanup (useful for debugging)
wct --skip-cleanup
# Use custom configuration file
wct --config-file custom-wct.conf.jsonManages Sauce Labs tunnel for remote testing via the wct-st command.
/**
* Sauce Labs tunnel runner for establishing secure connection to Sauce Labs
* @param env - Environment variables object
* @param args - Command line arguments array
* @param output - Output stream for writing results
* @returns Promise that resolves when tunnel is established
*/
function runSauceTunnel(env: any, args: string[], output: NodeJS.WritableStream): Promise<void>;Usage Examples:
# Start Sauce Labs tunnel
wct-st --username your-username --access-key your-key
# Start tunnel with specific tunnel identifier
wct-st --tunnel-id my-tunnel-123
# Start tunnel for specific browsers
wct-st --browsers chrome,firefox--version, -V # Show version number
--help, -h # Show help information
--verbose # Enable verbose logging
--quiet # Suppress output
--simpleOutput # Use simple output format
--skipUpdateCheck # Skip checking for updates--root <path> # Root directory for tests (default: current directory)
--suites <patterns> # Test file patterns to run
--timeout <ms> # Test timeout in milliseconds
--persistent # Keep browsers open after tests
--expanded # Show expanded test results--local <browser> # Run tests on local browser (chrome, firefox, safari, etc.)
--sauce # Run tests on Sauce Labs
--browsers <list> # Comma-separated list of browsers
--skip-selenium-install # Skip automatic Selenium installation--plugin <name> # Load specific plugin
--skip-plugin <name> # Skip loading specific plugin--config-file <path> # Path to custom configuration fileSAUCE_USERNAME # Sauce Labs username
SAUCE_ACCESS_KEY # Sauce Labs access key
SAUCE_TUNNEL_ID # Existing tunnel ID to useCI # Set to disable TTY output in CI environments
WCT_PACKAGE_NAME # Override package name for client-side codeThe CLI supports configuration via wct.conf.json files:
{
"verbose": true,
"root": "./",
"suites": ["test/**/*.html", "test/**/*.js"],
"plugins": {
"local": {
"browsers": ["chrome", "firefox"]
},
"sauce": {
"username": "your-username",
"accessKey": "your-key",
"browsers": [{
"browserName": "chrome",
"platform": "Windows 10"
}]
}
},
"clientOptions": {
"verbose": false,
"environmentScripts": []
}
}0 # Success - all tests passed
1 # Failure - tests failed or error occurred# .github/workflows/test.yml
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: npm install
- run: wct --local chrome --local firefox{
"scripts": {
"test": "wct",
"test:chrome": "wct --local chrome",
"test:sauce": "wct --sauce",
"test:debug": "wct --persistent --verbose"
}
}Install with Tessl CLI
npx tessl i tessl/npm-web-component-tester