intern
Version:
Intern. A next-generation code testing stack for JavaScript.
44 lines (43 loc) • 1.65 kB
TypeScript
import { CancellablePromise } from '@theintern/common';
import Benchmark from 'benchmark';
import Test, { TestFunction, TestProperties } from './Test';
import Deferred from './Deferred';
export default class BenchmarkTest extends Test {
test: BenchmarkTestFunction;
benchmark: InternBenchmark;
constructor(descriptor: BenchmarkTestOptions);
get timeElapsed(): number;
set timeElapsed(_value: number);
async(_timeout?: number, _numCallsUntilResolution?: number): Deferred<any>;
run(): CancellablePromise<void>;
toJSON(): {
[key: string]: any;
};
static async(testFunction: BenchmarkDeferredTestFunction, numCallsUntilResolution?: number): BenchmarkTestFunction;
}
export interface BenchmarkTestFunction extends TestFunction {
(this: BenchmarkTest): void | Promise<any>;
options?: BenchmarkOptions;
}
export interface BenchmarkDeferredTestFunction extends BenchmarkTestFunction {
(this: BenchmarkTest, deferred: Deferred<void>): void | Promise<any>;
options?: BenchmarkOptions;
}
export interface BenchmarkTestProperties extends TestProperties {
test: BenchmarkTestFunction;
skip: string;
numCallsUntilResolution: number;
}
export declare type BenchmarkTestOptions = Partial<BenchmarkTestProperties> & {
name: string;
test: BenchmarkTestFunction;
options?: BenchmarkOptions;
};
export interface BenchmarkOptions extends Benchmark.Options {
skip?: string;
numCallsUntilResolution?: number;
}
export interface InternBenchmark extends Benchmark {
internTest?: BenchmarkTest;
}
export declare function isBenchmarkTest(value: any): value is BenchmarkTest;