@types/karma
- Version 6.3.9
- Published
- 32.7 kB
- 2 dependencies
- MIT license
Install
npm i @types/karma
yarn add @types/karma
pnpm add @types/karma
Overview
TypeScript definitions for karma
Index
Variables
Classes
Interfaces
ConfigOptions
- autoWatch
- autoWatchBatchDelay
- basePath
- beforeMiddleware
- browserConsoleLogOptions
- browserDisconnectTimeout
- browserDisconnectTolerance
- browserNoActivityTimeout
- browsers
- browserSocketTimeout
- captureTimeout
- client
- colors
- concurrency
- crossOriginAttribute
- customClientContextFile
- customContextFile
- customDebugFile
- customHeaders
- customLaunchers
- detached
- exclude
- failOnEmptyTestSuite
- failOnFailingTestSuite
- failOnSkippedTests
- files
- forceJSONP
- formatError
- frameworks
- hostname
- httpModule
- httpsServerOptions
- listenAddress
- loggers
- logLevel
- middleware
- mime
- pingTimeout
- plugins
- port
- preprocessors
- processKillTimeout
- protocol
- proxies
- proxyReq
- proxyRes
- proxyValidateSSL
- reporters
- reportSlowerThan
- restartOnFileChange
- retryLimit
- singleRun
- transports
- upstreamProxy
- urlRoot
Type Aliases
Namespaces
Variables
Classes
class Server
class Server extends EventEmitter {}
constructor
constructor(options?: Config, callback?: ServerCallback);
constructor
constructor(options?: ConfigOptions | ConfigFile, callback?: ServerCallback);
Deprecated
method get
get: (token: string) => any;
Get properties from the injector
Parameter token
method on
on: { (event: string, listener: (...args: any[]) => void): this; ( event: 'run_complete', listener: (browsers: any, results: TestResults) => void ): this;};
Listen to the 'run_complete' event.
method refreshFile
refreshFile: (path: string) => Promise<any>;
method refreshFiles
refreshFiles: () => Promise<any>;
Force a refresh of the file list
method start
start: () => Promise<void>;
Start the server
method stop
stop: () => Promise<void>;
Stop the server
Interfaces
interface BrowserConsoleLogOptions
interface BrowserConsoleLogOptions {}
property format
format?: string | undefined;
The format is a string where
%b
,%t
,%T
, and%m
are replaced with the browser string, log type in lower-case, log type in uppercase, and log message, respectively. This format will only effect the output file
property level
level?: 'log' | 'error' | 'warn' | 'info' | 'debug' | undefined;
the desired log-level, where level log always is logged
property path
path?: string | undefined;
output-path of the output-file
property terminal
terminal?: boolean | undefined;
if the log should be written in the terminal, or not
interface ClientOptions
interface ClientOptions {}
property args
args?: string[] | undefined;
undefined When karma run is passed additional arguments on the command-line, they are passed through to the test adapter as karma.config.args (an array of strings). The client.args option allows you to set this value for actions other than run. How this value is used is up to your test adapter - you should check your adapter's documentation to see how (and if) it uses this value.
property captureConsole
captureConsole?: boolean | undefined;
true Capture all console output and pipe it to the terminal.
property clearContext
clearContext?: boolean | undefined;
true Clear the context window If true, Karma clears the context window upon the completion of running the tests. If false, Karma does not clear the context window upon the completion of running the tests. Setting this to false is useful when embedding a Jasmine Spec Runner Template.
property clientDisplayNone
clientDisplayNone?: boolean | undefined;
false Set style display none on client elements. If true, Karma does not display the banner and browser list. Useful when using karma on component tests with screenshots
property runInParent
runInParent?: boolean | undefined;
false Run the tests on the same window as the client, without using iframe or a new window
property useIframe
useIframe?: boolean | undefined;
true Run the tests inside an iFrame or a new window If true, Karma runs the tests inside an iFrame. If false, Karma runs the tests in a new window. Some tests may not run in an iFrame and may need a new window to run.
interface Config
interface Config {}
interface ConfigFile
interface ConfigFile {}
property configFile
configFile: string;
interface ConfigOptions
interface ConfigOptions {}
property autoWatch
autoWatch?: boolean | undefined;
Enable or disable watching files and executing the tests whenever one of these files changes. true
property autoWatchBatchDelay
autoWatchBatchDelay?: number | undefined;
When Karma is watching the files for changes, it tries to batch multiple changes into a single run so that the test runner doesn't try to start and restart running tests more than it should. The configuration setting tells Karma how long to wait (in milliseconds) after any changes have occurred before starting the test process again. 250
property basePath
basePath?: string | undefined;
'' The root path location that will be used to resolve all relative paths defined in files and exclude. If the basePath configuration is a relative path then it will be resolved to the __dirname of the configuration file.
property beforeMiddleware
beforeMiddleware?: string[] | undefined;
This is the same as middleware except that these middleware will be run before karma's own middleware. []
property browserConsoleLogOptions
browserConsoleLogOptions?: BrowserConsoleLogOptions | undefined;
Configure how the browser console is logged with the following properties, all of which are optional
property browserDisconnectTimeout
browserDisconnectTimeout?: number | undefined;
2000 How long does Karma wait for a browser to reconnect (in ms). With a flaky connection it is pretty common that the browser disconnects, but the actual test execution is still running without any problems. Karma does not treat a disconnection as immediate failure and will wait browserDisconnectTimeout (ms). If the browser reconnects during that time, everything is fine.
property browserDisconnectTolerance
browserDisconnectTolerance?: number | undefined;
0 The number of disconnections tolerated. The disconnectTolerance value represents the maximum number of tries a browser will attempt in the case of a disconnection. Usually any disconnection is considered a failure, but this option allows you to define a tolerance level when there is a flaky network link between the Karma server and the browsers.
property browserNoActivityTimeout
browserNoActivityTimeout?: number | undefined;
10000 How long will Karma wait for a message from a browser before disconnecting from it (in ms). If, during test execution, Karma does not receive any message from a browser within browserNoActivityTimeout (ms), it will disconnect from the browser
property browsers
browsers?: Array<AutomatedBrowsers | string> | undefined;
[] Possible Values: Chrome (launcher comes installed with Karma) ChromeCanary (launcher comes installed with Karma) PhantomJS (launcher comes installed with Karma) Firefox (launcher requires karma-firefox-launcher plugin) FirefoxHeadless (launcher requires karma-firefox-launcher plugin) FirefoxDeveloper (launcher requires karma-firefox-launcher plugin) FirefoxDeveloperHeadless (launcher requires karma-firefox-launcher plugin) FirefoxAurora (launcher requires karma-firefox-launcher plugin) FirefoxAuroraHeadless (launcher requires karma-firefox-launcher plugin) FirefoxNightly (launcher requires karma-firefox-launcher plugin) FirefoxNightlyHeadless (launcher requires karma-firefox-launcher plugin) Opera (launcher requires karma-opera-launcher plugin) Internet Explorer (launcher requires karma-ie-launcher plugin) Safari (launcher requires karma-safari-launcher plugin) A list of browsers to launch and capture. When Karma starts up, it will also start up each browser which is placed within this setting. Once Karma is shut down, it will shut down these browsers as well. You can capture any browser manually by opening the browser and visiting the URL where the Karma web server is listening (by default it is http://localhost:9876/).
property browserSocketTimeout
browserSocketTimeout?: number | undefined;
Timeout for the client socket connection (in ms) 20000
property captureTimeout
captureTimeout?: number | undefined;
60000 Timeout for capturing a browser (in ms). The captureTimeout value represents the maximum boot-up time allowed for a browser to start and connect to Karma. If any browser does not get captured within the timeout, Karma will kill it and try to launch it again and, after three attempts to capture it, Karma will give up.
property client
client?: ClientOptions | undefined;
property colors
colors?: boolean | undefined;
true Enable or disable colors in the output (reporters and logs).
property concurrency
concurrency?: number | undefined;
'Infinity' How many browsers Karma launches in parallel. Especially on services like SauceLabs and Browserstack, it makes sense only to launch a limited amount of browsers at once, and only start more when those have finished. Using this configuration, you can specify how many browsers should be running at once at any given point in time.
property crossOriginAttribute
crossOriginAttribute?: boolean | undefined;
When true, this will append the crossorigin attribute to generated script tags, which enables better error reporting for JavaScript files served from a different origin true
property customClientContextFile
customClientContextFile?: string | undefined;
If null (default), uses karma's own client_with_context.html file (which is used when client.runInParent set to true). undefined
property customContextFile
customContextFile?: string | undefined;
If null (default), uses karma's own context.html file. undefined
property customDebugFile
customDebugFile?: string | undefined;
If null (default), uses karma's own debug.html file. undefined
property customHeaders
customHeaders?: CustomHeaders[] | undefined;
Custom HTTP headers that will be set upon serving files by Karma's web server. Custom headers are useful, especially with upcoming browser features like Service Workers. undefined
property customLaunchers
customLaunchers?: { [key: string]: CustomLauncher } | undefined;
property detached
detached?: boolean | undefined;
When true, this will start the karma server in another process, writing no output to the console. The server can be stopped using the karma stop command. false
property exclude
exclude?: string[] | undefined;
[] List of files/patterns to exclude from loaded files.
property failOnEmptyTestSuite
failOnEmptyTestSuite?: boolean | undefined;
Enable or disable failure on running empty test-suites. If disabled the program will return exit-code 0 and display a warning. true
property failOnFailingTestSuite
failOnFailingTestSuite?: boolean | undefined;
Enable or disable failure on failing tests. true
property failOnSkippedTests
failOnSkippedTests?: boolean | undefined;
Enable or disable failure on tests deliberately disabled, eg fit() or xit() tests in jasmine. Use this to prevent accidental disabling tests needed to validate production. true
property files
files?: Array<FilePattern | string> | undefined;
[] List of files/patterns to load in the browser.
property forceJSONP
forceJSONP?: boolean | undefined;
Force socket.io to use JSONP polling instead of XHR polling false
property formatError
formatError?: ((msg: string) => string) | undefined;
A new error message line undefined
property frameworks
frameworks?: string[] | undefined;
[] List of test frameworks you want to use. Typically, you will set this to ['jasmine'], ['mocha'] or ['qunit']... Please note just about all frameworks in Karma require an additional plugin/framework library to be installed (via NPM).
property hostname
hostname?: string | undefined;
'localhost' Hostname to be used when capturing browsers.
property httpModule
httpModule?: string | undefined;
Module used for Karma webserver undefined
property httpsServerOptions
httpsServerOptions?: https.ServerOptions | undefined;
{} Options object to be used by Node's https class. Object description can be found in the [NodeJS.org API docs](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)
property listenAddress
listenAddress?: string | undefined;
Address that the server will listen on. Change to 'localhost' to only listen to the loopback, or '::' to listen on all IPv6 interfaces '0.0.0.0' or
LISTEN_ADDR
property loggers
loggers?: { [name: string]: Appender } | Appender[] | undefined;
[{type: 'console'}] A list of log appenders to be used. See the documentation for [log4js] for more information.
property logLevel
logLevel?: string | undefined;
config.LOG_INFO Possible values: config.LOG_DISABLE config.LOG_ERROR config.LOG_WARN config.LOG_INFO config.LOG_DEBUG Level of logging.
property middleware
middleware?: string[] | undefined;
[] List of names of additional middleware you want the Karma server to use. Middleware will be used in the order listed. You must have installed the middleware via a plugin/framework (either inline or via NPM). Additional information can be found in [plugins](http://karma-runner.github.io/2.0/config/plugins.html). The plugin must provide an express/connect middleware function (details about this can be found in the [Express](http://expressjs.com/guide/using-middleware.html) docs).
property mime
mime?: { [type: string]: string[] } | undefined;
{} Redefine default mapping from file extensions to MIME-type. Set property name to required MIME, provide Array of extensions (without dots) as it's value.
property pingTimeout
pingTimeout?: number | undefined;
Socket.io pingTimeout in ms, https://socket.io/docs/server-api/#new-Server-httpServer-options. Very slow networks may need values up to 60000. Larger values delay discovery of deadlock in tests or browser crashes. 5000
property plugins
plugins?: Array<PluginName | InlinePluginDef> | undefined;
['karma-*'] List of plugins to load. A plugin can be a string (in which case it will be required by Karma) or an inlined plugin - Object. By default, Karma loads all sibling NPM modules which have a name starting with karma-*. Note: Just about all plugins in Karma require an additional library to be installed (via NPM).
property port
port?: number | undefined;
9876 The port where the web server will be listening.
property preprocessors
preprocessors?: { [name: string]: string | string[] } | undefined;
{'**/*.coffee': 'coffee'} A map of preprocessors to use.
Preprocessors can be loaded through [plugins].
Note: Just about all preprocessors in Karma (other than CoffeeScript and some other defaults) require an additional library to be installed (via NPM).
Be aware that preprocessors may be transforming the files and file types that are available at run time. For instance, if you are using the "coverage" preprocessor on your source files, if you then attempt to interactively debug your tests, you'll discover that your expected source code is completely changed from what you expected. Because of that, you'll want to engineer this so that your automated builds use the coverage entry in the "reporters" list, but your interactive debugging does not.
property processKillTimeout
processKillTimeout?: number | undefined;
How long will Karma wait for browser process to terminate before sending a SIGKILL signal 2000
property protocol
protocol?: string | undefined;
'http:' Possible Values: http: https: Protocol used for running the Karma webserver. Determines the use of the Node http or https class. Note: Using 'https:' requires you to specify httpsServerOptions.
property proxies
proxies?: PathProxyPairs | undefined;
{} A map of path-proxy pairs The proxy can be specified directly by the target url or path, or with an object to configure more options
property proxyReq
proxyReq?: | ((proxyReq: any, req: any, res: any, options: object) => void) | undefined;
Called when requesting Proxy undefined
property proxyRes
proxyRes?: ((proxyRes: any, req: any, res: any) => void) | undefined;
Called when respnsing Proxy undefined
property proxyValidateSSL
proxyValidateSSL?: boolean | undefined;
true Whether or not Karma or any browsers should raise an error when an inavlid SSL certificate is found.
property reporters
reporters?: string[] | undefined;
['progress'] Possible Values: dots progress A list of reporters to use. Additional reporters, such as growl, junit, teamcity or coverage can be loaded through plugins. Note: Just about all additional reporters in Karma (other than progress) require an additional library to be installed (via NPM).
property reportSlowerThan
reportSlowerThan?: number | undefined;
0 Karma will report all the tests that are slower than given time limit (in ms). This is disabled by default (since the default value is 0).
property restartOnFileChange
restartOnFileChange?: boolean | undefined;
When Karma is watching the files for changes, it will delay a new run until the current run is finished. Enabling this setting will cancel the current run and start a new run immediately when a change is detected.
property retryLimit
retryLimit?: number | undefined;
When a browser crashes, karma will try to relaunch. This defines how many times karma should relaunch a browser before giving up. 2
property singleRun
singleRun?: boolean | undefined;
false Continuous Integration mode. If true, Karma will start and capture all configured browsers, run tests and then exit with an exit code of 0 or 1 depending on whether all tests passed or any tests failed.
property transports
transports?: string[] | undefined;
['polling', 'websocket'] An array of allowed transport methods between the browser and testing server. This configuration setting is handed off to [socket.io](http://socket.io/) (which manages the communication between browsers and the testing server).
property upstreamProxy
upstreamProxy?: UpstreamProxy | undefined;
For use when the Karma server needs to be run behind a proxy that changes the base url, etc
property urlRoot
urlRoot?: string | undefined;
'/' The base url, where Karma runs. All of Karma's urls get prefixed with the urlRoot. This is helpful when using proxies, as sometimes you might want to proxy a url that is already taken by Karma.
interface CustomHeaders
interface CustomHeaders {}
interface CustomLauncher
interface CustomLauncher {}
property base
base: string;
property browserName
browserName?: string | undefined;
property flags
flags?: string[] | undefined;
property platform
platform?: string | undefined;
interface FilePattern
interface FilePattern {}
property included
included?: boolean | undefined;
true Should the files be included in the browser using tag? Use false if you want to load them manually, eg. using Require.js.
property nocache
nocache?: boolean | undefined;
false Should the files be served from disk on each request by Karma's webserver?
property pattern
pattern: string;
The pattern to use for matching.
property served
served?: boolean | undefined;
true Should the files be served by Karma's webserver?
property type
type?: FilePatternTypes | undefined;
Choose the type to use when including a file 'js' The type determines the mechanism for including the file. The css and html types create link elements; the js and module elements create script elements. The dom type includes the file content in the page, used, for example, to test components combining HTML and JS.
property watched
watched?: boolean | undefined;
true If autoWatch is true all files that have set watched to true will be watched for changes.
interface PathProxyPairs
interface PathProxyPairs {}
A map of path-proxy pairs.
index signature
[path: string]: string | ProxyOptions;
interface ProxyOptions
interface ProxyOptions {}
property changeOrigin
changeOrigin?: boolean | undefined;
Whether or not the proxy should override the Host header using the host from the target false
property target
target: string;
The target url or path (mandatory)
interface Runner
interface Runner {}
method run
run: { (options?: Config, callback?: ServerCallback): void; (options?: ConfigOptions | ConfigFile, callback?: ServerCallback): void;};
Deprecated
interface Stopper
interface Stopper {}
method stop
stop: { (options?: Config, callback?: ServerCallback): void; (options?: ConfigOptions, callback?: ServerCallback): void;};
This function will signal a running server to stop. The equivalent of karma stop.
Deprecated
interface TestResults
interface TestResults {}
property disconnected
disconnected: boolean;
property error
error: boolean;
property exitCode
exitCode: number;
property failed
failed: number;
property success
success: number;
interface UpstreamProxy
interface UpstreamProxy {}
For use when the Karma server needs to be run behind a proxy that changes the base url, etc
property hostname
hostname?: string | undefined;
Will be used as the hostname when launching browsers 'localhost'
property path
path?: string | undefined;
Will be prepended to the base url when launching browsers and prepended to internal urls as loaded by the browsers '/'
property port
port?: number | undefined;
Will be used as the port when launching browsers 9875
property protocol
protocol?: string | undefined;
Will be used as the protocol when launching browsers 'http'
Type Aliases
type AutomatedBrowsers
type AutomatedBrowsers = | 'Chrome' | 'ChromeCanary' | 'ChromeHeadless' | 'PhantomJS' | 'Firefox' | 'FirefoxHeadless' | 'FirefoxDeveloper' | 'FirefoxDeveloperHeadless' | 'FirefoxAurora' | 'FirefoxAuroraHeadless' | 'FirefoxNightly' | 'FirefoxNightlyHeadless' | 'Opera' | 'IE' | 'Safari';
Available browser launchers -
Chrome
- launcher requireskarma-chrome-launcher
plugin -ChromeCanary
- launcher requireskarma-chrome-launcher
plugin -ChromeHeadless
- launcher requireskarma-chrome-launcher
plugin -PhantomJS
- launcher requireskarma-phantomjs-launcher
plugin -Firefox
- launcher requireskarma-firefox-launcher
plugin -FirefoxHeadless
- launcher requireskarma-firefox-launcher
plugin -FirefoxDeveloper
- launcher requireskarma-firefox-launcher
plugin -FirefoxDeveloperHeadless
- launcher requireskarma-firefox-launcher
plugin -FirefoxAurora
- launcher requireskarma-firefox-launcher
plugin -FirefoxAuroraHeadless
- launcher requireskarma-firefox-launcher
plugin -FirefoxNightly
- launcher requireskarma-firefox-launcher
plugin -FirefoxNightlyHeadless
- launcher requireskarma-firefox-launcher
plugin -Opera
- launcher requireskarma-opera-launcher
plugin -IE
- launcher requireskarma-ie-launcher
plugin -Safari
- launcher requires karma-safari-launcher plugin
type ConstructorFn
type ConstructorFn = Function | (new (...params: any[]) => any);
type ConstructorFnType
type ConstructorFnType = ['type', ConstructorFn];
type FactoryFn
type FactoryFn = (...params: any[]) => any;
type FactoryFnType
type FactoryFnType = ['factory', FactoryFn];
type FilePatternTypes
type FilePatternTypes = 'css' | 'html' | 'js' | 'module' | 'dom';
type to use when including a file
type InlinePluginDef
type InlinePluginDef = Record<PluginName, InlinePluginType>;
type InlinePluginType
type InlinePluginType = FactoryFnType | ConstructorFnType | ValueType;
type PluginName
type PluginName = string;
type ServerCallback
type ServerCallback = (exitCode: number) => void;
type ValueType
type ValueType = ['value', any];
Namespaces
namespace config
namespace config {}
function parseConfig
parseConfig: { (configFilePath: string, cliOptions: ConfigOptions): Config; ( configFilePath: string, cliOptions: ConfigOptions, parseOptions?: ParseOptions & { promiseConfig: true } ): Promise<Config>; ( configFilePath: string, cliOptions: ConfigOptions, parseOptions?: ParseOptions ): Config;};
namespace constants
module 'lib/constants.d.ts' {}
The current version of karma
variable COLOR_PATTERN
const COLOR_PATTERN: string;
The default color pattern for log output
variable CONSOLE_APPENDER
const CONSOLE_APPENDER: { type: string; layout: { type: string; pattern: string } };
The default console appender
variable DEFAULT_HOSTNAME
const DEFAULT_HOSTNAME: string;
The default hostname used for the karma server
variable DEFAULT_LISTEN_ADDR
const DEFAULT_LISTEN_ADDR: string;
The default listen address used for the karma server
variable DEFAULT_PORT
const DEFAULT_PORT: string | number;
The default port used for the karma server
variable EXIT_CODE
const EXIT_CODE: string;
The exit code
variable LOG_DEBUG
const LOG_DEBUG: string;
The value for the log
debug
level
variable LOG_DISABLE
const LOG_DISABLE: string;
The value for disabling logs
variable LOG_ERROR
const LOG_ERROR: string;
The value for the log
error
level
variable LOG_INFO
const LOG_INFO: string;
The value for the log
info
level
variable LOG_LOG
const LOG_LOG: string;
variable LOG_PRIORITIES
const LOG_PRIORITIES: ['OFF', 'ERROR', 'WARN', 'LOG', 'INFO', 'DEBUG'];
An array of log levels in descending order, i.e. LOG_DISABLE, LOG_ERROR, LOG_WARN, LOG_LOG, LOG_INFO, and LOG_DEBUG
variable LOG_WARN
const LOG_WARN: string;
The value for the log
warn
level
variable NO_COLOR_PATTERN
const NO_COLOR_PATTERN: string;
The default pattern for log output without color
variable VERSION
const VERSION: string;
The current version of karma
namespace launcher
namespace launcher {}
class Launcher
class Launcher {}
constructor
constructor(emitter: NodeJS.EventEmitter, injector: any);
method areAllCaptured
areAllCaptured: () => boolean;
method generateId
static generateId: () => string;
method kill
kill: (id: string, callback: () => void) => boolean;
method killAll
killAll: (callback: () => void) => void;
method launch
launch: ( names: string[], protocol: string, hostname: string, port: number, urlRoot: string) => any[];
method markCaptured
markCaptured: (id: string) => void;
method restart
restart: (id: string) => boolean;
Package Files (2)
Dependencies (2)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/karma
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/karma)
- HTML<a href="https://www.jsdocs.io/package/@types/karma"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2672 ms. - Missing or incorrect documentation? Open an issue for this package.