CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-web-component-tester

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.

Pending
Overview
Eval results
Files

cli.mddocs/

Command Line Interface

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.

Capabilities

Main CLI Command

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.json

Sauce Labs Tunnel Command

Manages 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

Command Line Options

General Options

--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

Test Configuration

--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

Browser Options

--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 Options

--plugin <name>       # Load specific plugin
--skip-plugin <name>  # Skip loading specific plugin

Configuration Files

--config-file <path>  # Path to custom configuration file

Environment Variables

Sauce Labs Configuration

SAUCE_USERNAME        # Sauce Labs username
SAUCE_ACCESS_KEY      # Sauce Labs access key  
SAUCE_TUNNEL_ID       # Existing tunnel ID to use

General Configuration

CI                    # Set to disable TTY output in CI environments
WCT_PACKAGE_NAME      # Override package name for client-side code

Configuration File Format

The 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": []
  }
}

Exit Codes

0    # Success - all tests passed
1    # Failure - tests failed or error occurred

Integration Examples

CI/CD Pipeline

# .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

NPM Scripts

{
  "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

docs

browser-environment.md

build-tools.md

cli.md

configuration.md

index.md

plugin-system.md

test-runner.md

tile.json