Test-framework agnostic JavaScript testing runner that supports TDD workflows and CI integration across multiple browsers and environments.
npx @tessl/cli install tessl/npm-testem@3.16.0Testem is a test-framework agnostic JavaScript testing runner that makes unit testing easy and enjoyable. It supports running tests across multiple browsers, Node.js, and other environments with both interactive TDD (Test-Driven Development) workflows and automated CI (Continuous Integration) execution.
npm install testem -gFor programmatic usage:
const Api = require('testem/lib/api');
const Config = require('testem/lib/config');For CLI usage, testem provides a global binary:
testem# Start interactive development mode
testem
# With specific configuration file
testem -f testem.json
# Launch specific browsers
testem -l Chrome,Firefox# Run tests in CI mode
testem ci
# With specific reporter
testem ci -R xunit
# Parallel execution
testem ci -P 5const Api = require('testem/lib/api');
// Development mode
const api = new Api();
api.startDev({
port: 7357,
launch: ['Chrome', 'Firefox']
});
// CI mode
api.startCI({
reporter: 'tap',
parallel: 3
}, (exitCode, error) => {
console.log('Tests completed with exit code:', exitCode);
});Testem is built around several key components:
Complete CLI for development and CI workflows with support for multiple test modes, browser launching, and configuration options.
testem [options] # Development mode
testem ci [options] # Continuous integration mode
testem server [options] # Server-only mode
testem launchers # List available launchersComprehensive configuration system supporting multiple file formats and extensive customization options for test execution, browser launching, and reporting.
// Configuration file formats supported
testem.json // JSON configuration
testem.yml // YAML configuration
testem.js // JavaScript configuration
.testem.json // Hidden JSON configuration
.testem.yml // Hidden YAML configuration
.testem.js // Hidden JavaScript configurationJavaScript API for integrating testem into build tools, custom workflows, and automated systems.
class Api {
startDev(options, finalizer): void;
startCI(options, finalizer): void;
startServer(options): void;
restart(): void;
setDefaultOptions(defaultOptions): void;
}
class Config {
constructor(appMode, progOptions, config);
read(callback): void;
get(key): any;
set(key, value): void;
}
class Server extends EventEmitter {
constructor(config);
start(callback): Promise<void>;
stop(callback): Promise<void>;
}Pluggable system for launching browsers and processes with built-in support for major browsers and custom launcher definitions.
class Launcher {
constructor(name, settings, config);
start(): Promise<void>;
kill(): Promise<void>;
isProcess(): boolean;
protocol(): string;
}
class LauncherFactory {
constructor(name, settings, config);
create(options): Launcher;
}Multiple output formats for test results including TAP, XUnit, dot notation, and TeamCity integration.
// Available reporters
const reporters = {
tap: TapReporter, // Test Anything Protocol
xunit: XUnitReporter, // XUnit XML format
dot: DotReporter, // Dot progress indicator
teamcity: TeamCityReporter, // TeamCity integration
dev: DevReporter // Interactive development UI
};interface TestemOptions {
file?: string; // Configuration file path
port?: number; // Server port (default: 7357)
host?: string; // Server host (default: localhost)
launch?: string[]; // Launchers to use
skip?: string[]; // Launchers to skip
debug?: boolean | string; // Debug mode or log file
test_page?: string | string[]; // Custom test page(s)
growl?: boolean; // Enable notifications
timeout?: number; // Browser timeout
parallel?: number; // Parallel runners (CI mode)
reporter?: string; // Test reporter
bail_on_uncaught_error?: boolean; // Exit on uncaught errors
}
interface ConfigOptions extends TestemOptions {
framework?: string; // Test framework (jasmine, qunit, mocha)
src_files?: string[]; // Source files to include
src_files_ignore?: string[]; // Files to exclude
serve_files?: string[]; // Files to serve to browser
watch_files?: string[]; // Files to watch for changes
css_files?: string[]; // CSS files to include
cwd?: string; // Working directory
config_dir?: string; // Config directory
launchers?: object; // Custom launcher definitions
launch_in_dev?: string[]; // Dev mode launchers
launch_in_ci?: string[]; // CI mode launchers
routes?: object; // Custom routes
proxies?: object; // Proxy configuration
middleware?: Function[]; // Express middleware
browser_args?: object; // Browser-specific arguments
browser_paths?: object; // Custom browser paths
browser_exes?: object; // Custom browser executables
}