mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Preparing for mocha 8 (#46017)
* Mocha parallel and jobs options * Remove deprecated functions * Removed deprecated types * Replace MochaSetupOptions for MochaOptions in browser mode * Update deps to not use deprecated interfaces * Added unloadFiles to mocha
This commit is contained in:
parent
92a75538fb
commit
ee044bd8fa
4
types/bardjs/index.d.ts
vendored
4
types/bardjs/index.d.ts
vendored
@ -115,7 +115,7 @@ declare namespace bard {
|
||||
* [strings] - same string array you'd use to set fn.$inject
|
||||
* (...string) - string arguments turned into a string array
|
||||
*/
|
||||
function inject(context?: Function | Mocha.IHookCallbackContext, ...args: string[]): void;
|
||||
function inject(context?: Function | Mocha.Context, ...args: string[]): void;
|
||||
|
||||
/**
|
||||
* Write to console if bard debugging flag is on
|
||||
@ -128,7 +128,7 @@ declare namespace bard {
|
||||
* var runner = mocha.run();
|
||||
* bard.mochaRunnerListener(runner);
|
||||
*/
|
||||
function mochaRunnerListener(runner: Mocha.IRunner): void;
|
||||
function mochaRunnerListener(runner: Mocha.Runner): void;
|
||||
|
||||
/**
|
||||
* Mocks out a service with sinon stubbed functions
|
||||
|
||||
@ -9,7 +9,7 @@ expect({}).to.matchSnapshot("filename");
|
||||
expect({}).to.matchSnapshot("filename", "snapshotname");
|
||||
expect({}).to.matchSnapshot("filename", "snapshotname", false);
|
||||
|
||||
const mockContext: Mocha.IBeforeAndAfterContext = <any> {
|
||||
const mockContext: Mocha.Context = <any> {
|
||||
currentTest: {
|
||||
file: 'testfile',
|
||||
fullTitle: () => 'fullTitle'
|
||||
|
||||
2
types/chai-jest-snapshot/index.d.ts
vendored
2
types/chai-jest-snapshot/index.d.ts
vendored
@ -27,7 +27,7 @@ interface ChaiJestSnapshot extends Chai.ChaiPlugin {
|
||||
setTestName(testname: string): void;
|
||||
|
||||
/** Configure snapshot name using mocha context */
|
||||
configureUsingMochaContext(context: Mocha.IBeforeAndAfterContext): void;
|
||||
configureUsingMochaContext(context: Mocha.Context): void;
|
||||
|
||||
/** Reset snapshot registry */
|
||||
resetSnapshotRegistry(): void;
|
||||
|
||||
10
types/ember-mocha/index.d.ts
vendored
10
types/ember-mocha/index.d.ts
vendored
@ -11,7 +11,7 @@
|
||||
|
||||
import { TestContext, ModuleCallbacks } from "ember-test-helpers";
|
||||
import Ember from 'ember';
|
||||
import { it as mochaIt, ISuiteCallbackContext } from 'mocha';
|
||||
import { it as mochaIt, Suite } from 'mocha';
|
||||
|
||||
// these globals are re-exported as named exports by ember-mocha
|
||||
type mochaBefore = typeof before;
|
||||
@ -25,10 +25,10 @@ type mochaSuiteTeardown = typeof suiteTeardown;
|
||||
|
||||
declare module 'ember-mocha' {
|
||||
interface ContextDefinitionFunction {
|
||||
(name: string, description: string, callbacks: ModuleCallbacks, tests: (this: ISuiteCallbackContext) => void): void;
|
||||
(name: string, description: string, tests: (this: ISuiteCallbackContext) => void): void;
|
||||
(name: string, callbacks: ModuleCallbacks, tests: (this: ISuiteCallbackContext) => void): void;
|
||||
(name: string, tests: (this: ISuiteCallbackContext) => void): void;
|
||||
(name: string, description: string, callbacks: ModuleCallbacks, tests: (this: Suite) => void): void;
|
||||
(name: string, description: string, tests: (this: Suite) => void): void;
|
||||
(name: string, callbacks: ModuleCallbacks, tests: (this: Suite) => void): void;
|
||||
(name: string, tests: (this: Suite) => void): void;
|
||||
}
|
||||
|
||||
interface ContextDefinition extends ContextDefinitionFunction {
|
||||
|
||||
2
types/gulp-mocha/index.d.ts
vendored
2
types/gulp-mocha/index.d.ts
vendored
@ -8,6 +8,6 @@
|
||||
/// <reference types="node"/>
|
||||
|
||||
|
||||
declare function mocha(setupOptions?: MochaSetupOptions): NodeJS.ReadWriteStream;
|
||||
declare function mocha(setupOptions?: Mocha.MochaOptions): NodeJS.ReadWriteStream;
|
||||
declare namespace mocha { }
|
||||
export = mocha;
|
||||
|
||||
338
types/mocha/index.d.ts
vendored
338
types/mocha/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for mocha 7.0
|
||||
// Type definitions for mocha 8.0
|
||||
// Project: https://mochajs.org
|
||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid>
|
||||
// otiai10 <https://github.com/otiai10>
|
||||
@ -90,13 +90,6 @@ declare class Mocha {
|
||||
*/
|
||||
invert(): this;
|
||||
|
||||
/**
|
||||
* Ignore global leaks.
|
||||
*
|
||||
* @see https://mochajs.org/api/mocha#ignoreLeaks
|
||||
*/
|
||||
ignoreLeaks(ignore: boolean): this;
|
||||
|
||||
/**
|
||||
* Enable global leak checking.
|
||||
*
|
||||
@ -125,27 +118,6 @@ declare class Mocha {
|
||||
*/
|
||||
globals(globals: string | ReadonlyArray<string>): this;
|
||||
|
||||
/**
|
||||
* Emit color output.
|
||||
*
|
||||
* @see https://mochajs.org/api/mocha#useColors
|
||||
*/
|
||||
useColors(colors: boolean): this;
|
||||
|
||||
/**
|
||||
* Use inline diffs rather than +/-.
|
||||
*
|
||||
* @see https://mochajs.org/api/mocha#useInlineDiffs
|
||||
*/
|
||||
useInlineDiffs(inlineDiffs: boolean): this;
|
||||
|
||||
/**
|
||||
* Do not show diffs at all.
|
||||
*
|
||||
* @see https://mochajs.org/api/mocha#hideDiff
|
||||
*/
|
||||
hideDiff(hideDiff: boolean): this;
|
||||
|
||||
/**
|
||||
* Set the timeout in milliseconds.
|
||||
*
|
||||
@ -167,13 +139,6 @@ declare class Mocha {
|
||||
*/
|
||||
slow(slow: string | number): this;
|
||||
|
||||
/**
|
||||
* Enable timeouts.
|
||||
*
|
||||
* @see https://mochajs.org/api/mocha#enableTimeouts
|
||||
*/
|
||||
enableTimeouts(enabled?: boolean): this;
|
||||
|
||||
/**
|
||||
* Makes all tests async (accepting a callback)
|
||||
*
|
||||
@ -244,6 +209,25 @@ declare class Mocha {
|
||||
* @see https://mochajs.org/api/mocha#loadFiles
|
||||
*/
|
||||
protected loadFiles(fn?: () => void): void;
|
||||
|
||||
/**
|
||||
* Unloads `files` from Node's `require` cache.
|
||||
*
|
||||
* This allows required files to be "freshly" reloaded, providing the ability
|
||||
* to reuse a Mocha instance programmatically.
|
||||
* Note: does not clear ESM module files from the cache
|
||||
*/
|
||||
unloadFiles(): this;
|
||||
|
||||
/**
|
||||
* Toggles parallel mode.
|
||||
*
|
||||
* Must be run before calling `run`. Changes the `Runner` class to
|
||||
* use; also enables lazy file loading if not already done so.
|
||||
*
|
||||
* @see https://mochajs.org/api/mocha#parallelMode
|
||||
*/
|
||||
parallelMode(enabled?: boolean): this;
|
||||
}
|
||||
|
||||
declare namespace Mocha {
|
||||
@ -691,8 +675,6 @@ declare namespace Mocha {
|
||||
*/
|
||||
class Base {
|
||||
constructor(runner: Runner, options?: MochaOptions);
|
||||
/** @deprecated Use the overload that accepts `Mocha.Runner` instead. */
|
||||
constructor(runner: IRunner, options?: MochaOptions);
|
||||
|
||||
/**
|
||||
* Test run statistics
|
||||
@ -981,8 +963,6 @@ declare namespace Mocha {
|
||||
*/
|
||||
class XUnit extends Base {
|
||||
constructor(runner: Runner, options?: XUnit.MochaOptions);
|
||||
/** @deprecated Use the overload that accepts `Mocha.Runner` instead. */
|
||||
constructor(runner: IRunner, options?: XUnit.MochaOptions);
|
||||
|
||||
/**
|
||||
* Override done to close the stream (if it's a file).
|
||||
@ -1032,8 +1012,6 @@ declare namespace Mocha {
|
||||
*/
|
||||
class Progress extends Base {
|
||||
constructor(runner: Runner, options?: Progress.MochaOptions);
|
||||
/** @deprecated Use the overload that accepts `Mocha.Runner` instead. */
|
||||
constructor(runner: IRunner, options?: Progress.MochaOptions);
|
||||
}
|
||||
|
||||
namespace Progress {
|
||||
@ -1091,7 +1069,6 @@ declare namespace Mocha {
|
||||
*/
|
||||
class Runnable {
|
||||
private _slow;
|
||||
private _enableTimeouts;
|
||||
private _retries;
|
||||
private _currentRetry;
|
||||
private _timeout;
|
||||
@ -1143,20 +1120,6 @@ declare namespace Mocha {
|
||||
*/
|
||||
slow(ms: string | number): this;
|
||||
|
||||
/**
|
||||
* Get whether timeouts are enabled.
|
||||
*
|
||||
* @see https://mochajs.org/api/Runnable.html#enableTimeouts
|
||||
*/
|
||||
enableTimeouts(): boolean;
|
||||
|
||||
/**
|
||||
* Set whether timeouts are enabled.
|
||||
*
|
||||
* @see https://mochajs.org/api/Runnable.html#enableTimeouts
|
||||
*/
|
||||
enableTimeouts(enabled: boolean): this;
|
||||
|
||||
/**
|
||||
* Halt and mark as pending.
|
||||
*/
|
||||
@ -1303,8 +1266,6 @@ declare namespace Mocha {
|
||||
* Set the context `Runnable`.
|
||||
*/
|
||||
runnable(runnable: Runnable): this;
|
||||
/** @deprecated Use the overload that accepts `Mocha.Runnable` instead. */
|
||||
runnable(runnable: IRunnable): this;
|
||||
|
||||
/**
|
||||
* Get test timeout.
|
||||
@ -1316,16 +1277,6 @@ declare namespace Mocha {
|
||||
*/
|
||||
timeout(ms: string | number): this;
|
||||
|
||||
/**
|
||||
* Get whether timeouts are enabled.
|
||||
*/
|
||||
enableTimeouts(): boolean;
|
||||
|
||||
/**
|
||||
* Set whether timeouts are enabled.
|
||||
*/
|
||||
enableTimeouts(enabled: boolean): this;
|
||||
|
||||
/**
|
||||
* Get test slowness threshold.
|
||||
*/
|
||||
@ -1390,9 +1341,6 @@ declare namespace Mocha {
|
||||
|
||||
constructor(suite: Suite, delay: boolean);
|
||||
|
||||
/** @deprecated Use the overload that accepts `Mocha.Suite` instead. */
|
||||
constructor(suite: ISuite, delay: boolean);
|
||||
|
||||
suite: Suite;
|
||||
started: boolean;
|
||||
total: number;
|
||||
@ -1423,9 +1371,6 @@ declare namespace Mocha {
|
||||
*/
|
||||
grepTotal(suite: Suite): number;
|
||||
|
||||
/** @deprecated Use the overload that accepts `Mocha.Suite` instead. */
|
||||
grepTotal(suite: ISuite): number;
|
||||
|
||||
/**
|
||||
* Gets the allowed globals.
|
||||
*
|
||||
@ -1739,7 +1684,6 @@ declare namespace Mocha {
|
||||
private _afterEach;
|
||||
private _afterAll;
|
||||
private _timeout;
|
||||
private _enableTimeouts;
|
||||
private _slow;
|
||||
private _bail;
|
||||
private _retries;
|
||||
@ -1749,8 +1693,6 @@ declare namespace Mocha {
|
||||
static readonly constants: SuiteConstants;
|
||||
|
||||
constructor(title: string, parentContext?: Context);
|
||||
/** @deprecated Use the overload that accepts `Mocha.Context` instead. */
|
||||
constructor(title: string, parentContext?: IContext);
|
||||
|
||||
ctx: Context;
|
||||
suites: Suite[];
|
||||
@ -1770,8 +1712,6 @@ declare namespace Mocha {
|
||||
* @see https://mochajs.org/api/mocha#.exports.create
|
||||
*/
|
||||
static create(parent: Suite, title: string): Suite;
|
||||
/** @deprecated Use the overload that accepts `Mocha.Suite` instead. */
|
||||
static create(parent: ISuite, title: string): Suite;
|
||||
|
||||
/**
|
||||
* Return a clone of this `Suite`.
|
||||
@ -1808,20 +1748,6 @@ declare namespace Mocha {
|
||||
*/
|
||||
retries(n: string | number): this;
|
||||
|
||||
/**
|
||||
* Get whether timeouts are enabled.
|
||||
*
|
||||
* @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts
|
||||
*/
|
||||
enableTimeouts(): boolean;
|
||||
|
||||
/**
|
||||
* Set whether timeouts are `enabled`.
|
||||
*
|
||||
* @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts
|
||||
*/
|
||||
enableTimeouts(enabled: boolean): this;
|
||||
|
||||
/**
|
||||
* Get slow `ms`.
|
||||
*
|
||||
@ -1975,8 +1901,6 @@ declare namespace Mocha {
|
||||
* @see https://mochajs.org/api/Mocha.Suite.html#addSuite
|
||||
*/
|
||||
addSuite(suite: Suite): this;
|
||||
/** @deprecated Use the overload that accepts `Mocha.ISuite` instead. */
|
||||
addSuite(suite: ISuite): this;
|
||||
|
||||
/**
|
||||
* Add a `test` to this suite.
|
||||
@ -1984,8 +1908,6 @@ declare namespace Mocha {
|
||||
* @see https://mochajs.org/api/Mocha.Suite.html#addTest
|
||||
*/
|
||||
addTest(test: Test): this;
|
||||
/** @deprecated Use the overload that accepts `Mocha.ITest` instead. */
|
||||
addTest(test: ITest): this;
|
||||
|
||||
/**
|
||||
* Return the full title generated by recursively concatenating the parent's
|
||||
@ -2245,8 +2167,6 @@ declare namespace Mocha {
|
||||
/** timeout in milliseconds or time string like '1s'. */
|
||||
timeout?: number | string;
|
||||
|
||||
enableTimeouts?: boolean;
|
||||
|
||||
/** number of times to retry failed tests. */
|
||||
retries?: number;
|
||||
|
||||
@ -2268,13 +2188,6 @@ declare namespace Mocha {
|
||||
/** Enable growl support. */
|
||||
growl?: boolean;
|
||||
|
||||
/**
|
||||
* Emit color output.
|
||||
*
|
||||
* @deprecated use `color` instead.
|
||||
*/
|
||||
useColors?: boolean;
|
||||
|
||||
/** Color TTY output from reporter */
|
||||
color?: boolean;
|
||||
|
||||
@ -2284,12 +2197,22 @@ declare namespace Mocha {
|
||||
/** Do not show diffs at all. */
|
||||
hideDiff?: boolean;
|
||||
|
||||
/** Run job in parallel */
|
||||
parallel?: boolean;
|
||||
|
||||
/** Max number of worker processes for parallel runs */
|
||||
jobs?: number;
|
||||
|
||||
/** Assigns hooks to the root suite */
|
||||
rootHooks?: any;
|
||||
|
||||
asyncOnly?: boolean;
|
||||
delay?: boolean;
|
||||
forbidOnly?: boolean;
|
||||
forbidPending?: boolean;
|
||||
noHighlighting?: boolean;
|
||||
allowUncaught?: boolean;
|
||||
fullTrace?: boolean;
|
||||
}
|
||||
|
||||
interface MochaInstanceOptions extends MochaOptions {
|
||||
@ -2494,186 +2417,6 @@ declare namespace Mocha {
|
||||
}
|
||||
|
||||
type Interface = keyof InterfaceContributions;
|
||||
|
||||
// #region Deprecations
|
||||
|
||||
/** @deprecated use `Mocha.Context` instead. */
|
||||
interface IContext {
|
||||
test?: IRunnable;
|
||||
runnable(): IRunnable | undefined;
|
||||
/** @deprecated `.runnable()` returns `this` in `Mocha.Context`. */
|
||||
runnable(runnable: IRunnable): IContext;
|
||||
timeout(): number;
|
||||
/** @deprecated `.timeout()` returns `this` in `Mocha.Context`. */
|
||||
timeout(timeout: number): IContext;
|
||||
/** @deprecated `.enableTimeouts()` has additional overloads in `Mocha.Context`. */
|
||||
/** @deprecated `.enableTimeouts()` returns `this` in `Mocha.Context`. */
|
||||
enableTimeouts(enableTimeouts: boolean): IContext;
|
||||
/** @deprecated `.slow()` has additional overloads in `Mocha.Context`. */
|
||||
/** @deprecated `.slow()` returns `this` in `Mocha.Context`. */
|
||||
slow(slow: number): IContext;
|
||||
/** @deprecated `.skip()` returns `never` in `Mocha.Context`. */
|
||||
skip(): IContext;
|
||||
retries(): number;
|
||||
/** @deprecated `.retries()` returns `this` in `Mocha.Context`. */
|
||||
retries(retries: number): IContext;
|
||||
}
|
||||
|
||||
/** @deprecated use `Mocha.Suite` instead. */
|
||||
interface ISuiteCallbackContext {
|
||||
/** @deprecated `.timeout()` has additional overloads in `Mocha.Suite`. */
|
||||
timeout(ms: number | string): this;
|
||||
/** @deprecated `.retries()` has additional overloads in `Mocha.Suite`. */
|
||||
retries(n: number): this;
|
||||
/** @deprecated `.slow()` has additional overloads in `Mocha.Suite`. */
|
||||
slow(ms: number): this;
|
||||
}
|
||||
|
||||
/** @deprecated use `Mocha.Context` instead. */
|
||||
interface IHookCallbackContext {
|
||||
/** @deprecated `.skip()` returns `never` in `Mocha.Context`. */
|
||||
skip(): this;
|
||||
/** @deprecated `.timeout()` has additional overloads in `Mocha.Context`. */
|
||||
timeout(ms: number | string): this;
|
||||
[index: string]: any;
|
||||
}
|
||||
|
||||
/** @deprecated use `Mocha.Context` instead. */
|
||||
interface ITestCallbackContext {
|
||||
/** @deprecated `.skip()` returns `never` in `Mocha.Context`. */
|
||||
skip(): this;
|
||||
/** @deprecated `.timeout()` has additional overloads in `Mocha.Context`. */
|
||||
timeout(ms: number | string): this;
|
||||
/** @deprecated `.retries()` has additional overloads in `Mocha.Context`. */
|
||||
retries(n: number): this;
|
||||
/** @deprecated `.slow()` has additional overloads in `Mocha.Context`. */
|
||||
slow(ms: number): this;
|
||||
[index: string]: any;
|
||||
}
|
||||
|
||||
/** Partial interface for Mocha's `Runnable` class. */
|
||||
/** @deprecated use `Mocha.Runnable` instead. */
|
||||
interface IRunnable extends NodeJS.EventEmitter {
|
||||
title: string;
|
||||
/** @deprecated `.fn` has type `Func | AsyncFunc` in `Mocha.Runnable`. */
|
||||
fn: Function | undefined;
|
||||
async: boolean;
|
||||
sync: boolean;
|
||||
timedOut: boolean;
|
||||
/** @deprecated `.timeout()` has additional overloads in `Mocha.Runnable`. */
|
||||
timeout(n: number | string): this;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
/** Partial interface for Mocha's `Suite` class. */
|
||||
/** @deprecated use `Mocha.Suite` instead. */
|
||||
interface ISuite {
|
||||
/** @deprecated `.ctx` has type `Mocha.Context` in `Mocha.Suite`. */
|
||||
ctx: IContext;
|
||||
/** @deprecated `.parent` has type `Mocha.Suite | undefined` in `Mocha.Suite`. */
|
||||
parent: ISuite | undefined;
|
||||
root: boolean;
|
||||
title: string;
|
||||
/** @deprecated `.suites` has type `Mocha.Suite[]` in `Mocha.Suite`. */
|
||||
suites: ISuite[];
|
||||
/** @deprecated `.tests` has type `Mocha.Test[]` in `Mocha.Suite`. */
|
||||
tests: ITest[];
|
||||
|
||||
bail(): boolean;
|
||||
/** @deprecated `.bail()` returns `this` in `Mocha.Suite`. */
|
||||
bail(bail: boolean): ISuite;
|
||||
fullTitle(): string;
|
||||
retries(): number;
|
||||
/** @deprecated `.retries()` returns `this` in `Mocha.Suite`. */
|
||||
retries(retries: number): ISuite;
|
||||
slow(): number;
|
||||
/** @deprecated `.slow()` returns `this` in `Mocha.Suite`. */
|
||||
slow(slow: number): ISuite;
|
||||
timeout(): number;
|
||||
/** @deprecated `.timeout()` returns `this` in `Mocha.Suite`. */
|
||||
timeout(timeout: number): ISuite;
|
||||
}
|
||||
|
||||
/** Partial interface for Mocha's `Test` class. */
|
||||
/** @deprecated use `Mocha.Test` instead. */
|
||||
interface ITest extends IRunnable {
|
||||
body?: string;
|
||||
file?: string;
|
||||
/** @deprecated `.parent` has type `Mocha.Suite | undefined` in `Mocha.Test`. */
|
||||
parent?: ISuite;
|
||||
pending: boolean;
|
||||
state?: 'failed' | 'passed';
|
||||
type: 'test';
|
||||
fullTitle(): string;
|
||||
}
|
||||
|
||||
/** @deprecated use `Mocha.Hook` instead. */
|
||||
interface IHook extends IRunnable {
|
||||
/** @deprecated `.ctx` has type `Mocha.Context` in `Mocha.Runnable`. */
|
||||
ctx?: IContext;
|
||||
/** @deprecated `.parent` has type `Mocha.Suite` in `Mocha.Runnable`. */
|
||||
parent?: ISuite;
|
||||
type: 'hook';
|
||||
/** @deprecated `.error()` has additional overloads in `Mocha.Hook`. */
|
||||
error(err: Error): void;
|
||||
}
|
||||
|
||||
/** @deprecated use `Mocha.Context` instead. */
|
||||
interface IBeforeAndAfterContext extends IHookCallbackContext {
|
||||
/** @deprecated `.currentTest` has type `Mocha.Test` in `Mocha.Context`. */
|
||||
currentTest?: ITest;
|
||||
}
|
||||
|
||||
/** @deprecated use `Mocha.Stats` instead. */
|
||||
type IStats = Stats;
|
||||
|
||||
/** Partial interface for Mocha's `Runner` class. */
|
||||
/** @deprecated use `Mocha.Runner` instead. */
|
||||
interface IRunner extends NodeJS.EventEmitter {
|
||||
asyncOnly?: boolean;
|
||||
stats?: IStats;
|
||||
started: boolean;
|
||||
/** @deprecated `.suite` has type `Mocha.Suite` in `Mocha.Runner`. */
|
||||
suite: ISuite;
|
||||
total: number;
|
||||
failures: number;
|
||||
forbidOnly?: boolean;
|
||||
forbidPending?: boolean;
|
||||
fullStackTrace?: boolean;
|
||||
ignoreLeaks?: boolean;
|
||||
grep(re: RegExp, invert: boolean): this;
|
||||
/** @deprecated Parameter `suite` has type `Mocha.Suite` in `Mocha.Runner`. */
|
||||
grepTotal(suite: ISuite): number;
|
||||
/** @deprecated `.globals()` has different overloads in `Mocha.Runner`. */
|
||||
globals(arr: ReadonlyArray<string>): this | string[];
|
||||
abort(): this;
|
||||
run(fn?: (failures: number) => void): this;
|
||||
}
|
||||
|
||||
/** @deprecated use `Mocha.SuiteFunction` instead. */
|
||||
interface IContextDefinition {
|
||||
/** @deprecated use `Mocha.SuiteFunction` instead. */
|
||||
(description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
|
||||
/** @deprecated use `Mocha.SuiteFunction` instead. */
|
||||
only(description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
|
||||
/** @deprecated use `Mocha.SuiteFunction` instead. */
|
||||
skip(description: string, callback: (this: ISuiteCallbackContext) => void): void;
|
||||
}
|
||||
|
||||
/** @deprecated use `Mocha.TestFunction` instead. */
|
||||
interface ITestDefinition {
|
||||
/** @deprecated use `Mocha.TestFunction` instead. */
|
||||
/** @deprecated `Mocha.TestFunction` does not allow mixing `done` with a return type of `PromiseLike<any>`. */
|
||||
(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => PromiseLike<any> | void): ITest;
|
||||
/** @deprecated use `Mocha.TestFunction` instead. */
|
||||
/** @deprecated `Mocha.TestFunction#only` does not allow mixing `done` with a return type of `PromiseLike<any>`. */
|
||||
only(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => PromiseLike<any> | void): ITest;
|
||||
/** @deprecated use `Mocha.TestFunction` instead. */
|
||||
/** @deprecated `Mocha.TestFunction#skip` does not allow mixing `done` with a return type of `PromiseLike<any>`. */
|
||||
skip(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => PromiseLike<any> | void): void;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
}
|
||||
|
||||
// #region Test interface augmentations
|
||||
@ -2882,30 +2625,11 @@ interface BrowserMocha extends Mocha {
|
||||
*
|
||||
* - _Only supported in the browser._
|
||||
*/
|
||||
setup(opts?: Mocha.Interface | MochaSetupOptions): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to pass to `mocha.setup` in the browser.
|
||||
*/
|
||||
interface MochaSetupOptions extends Mocha.MochaOptions {
|
||||
/** @deprecated This is not used by Mocha. Use `files` instead. */
|
||||
require?: string[];
|
||||
fullTrace?: boolean;
|
||||
setup(opts?: Mocha.Interface | Mocha.MochaOptions): this;
|
||||
}
|
||||
|
||||
// #endregion Browser augmentations
|
||||
|
||||
// #region Deprecations
|
||||
|
||||
/** @deprecated use `Mocha.Done` instead. */
|
||||
type MochaDone = Mocha.Done;
|
||||
|
||||
/** @deprecated use `Mocha.ReporterConstructor` instead. */
|
||||
type ReporterConstructor = Mocha.ReporterConstructor;
|
||||
|
||||
// #endregion Deprecations
|
||||
|
||||
declare module "mocha" {
|
||||
export = Mocha;
|
||||
}
|
||||
|
||||
@ -695,12 +695,6 @@ function test_Context(ctx: LocalMocha.Context, runnable: LocalMocha.Runnable) {
|
||||
// $ExpectType never
|
||||
ctx.skip(); // throws
|
||||
|
||||
// $ExpectType boolean
|
||||
ctx.enableTimeouts();
|
||||
|
||||
// $ExpectType Context
|
||||
ctx.enableTimeouts(boolean);
|
||||
|
||||
// $ExpectType number
|
||||
ctx.retries();
|
||||
|
||||
@ -736,8 +730,7 @@ function test_Context(ctx: LocalMocha.Context, runnable: LocalMocha.Runnable) {
|
||||
// $ExpectType any
|
||||
ctx["extended"];
|
||||
|
||||
ctx.enableTimeouts(boolean)
|
||||
.retries(number)
|
||||
ctx.retries(number)
|
||||
.runnable(runnable)
|
||||
.slow(number)
|
||||
.timeout(number)
|
||||
@ -783,11 +776,6 @@ function test_browser_mocha_setup_reporter_string_option() {
|
||||
mocha.setup({ reporter: 'html' });
|
||||
}
|
||||
|
||||
function test_browser_mocha_setup_require_stringArray_option() {
|
||||
// $ExpectType BrowserMocha
|
||||
mocha.setup({ require: ['ts-node/register'] });
|
||||
}
|
||||
|
||||
function test_browser_mocha_setup_reporter_function_option() {
|
||||
// $ExpectType BrowserMocha
|
||||
mocha.setup({ reporter: class extends LocalMocha.reporters.Base { } });
|
||||
@ -798,11 +786,6 @@ function test_browser_mocha_setup_bail_option() {
|
||||
mocha.setup({ bail: false });
|
||||
}
|
||||
|
||||
function test_browser_mocha_setup_ignore_leaks_option() {
|
||||
// $ExpectType BrowserMocha
|
||||
mocha.setup({ ignoreLeaks: false });
|
||||
}
|
||||
|
||||
function test_browser_mocha_setup_grep_string_option() {
|
||||
// $ExpectType BrowserMocha
|
||||
mocha.setup({ grep: "describe" });
|
||||
@ -827,9 +810,7 @@ function test_browser_mocha_setup_all_options() {
|
||||
globals: ['mocha'],
|
||||
reporter: 'html',
|
||||
bail: true,
|
||||
ignoreLeaks: true,
|
||||
grep: 'test',
|
||||
require: ['ts-node/register'] // TODO: It doesn't appear this is actually supported. Should it be removed?
|
||||
grep: 'test'
|
||||
});
|
||||
}
|
||||
|
||||
@ -837,6 +818,14 @@ function testLoadFilesAsync() {
|
||||
mocha.loadFilesAsync();
|
||||
}
|
||||
|
||||
function testParallelMode() {
|
||||
mocha.parallelMode();
|
||||
}
|
||||
|
||||
function testUnloadFiles() {
|
||||
mocha.unloadFiles();
|
||||
}
|
||||
|
||||
function test_constructor_slow_option() {
|
||||
const m: Mocha = new LocalMocha({ slow: 25 });
|
||||
}
|
||||
@ -869,10 +858,6 @@ function test_constructor_bail_option() {
|
||||
const m: Mocha = new LocalMocha({ bail: false });
|
||||
}
|
||||
|
||||
function test_constructor_ignore_leaks_option() {
|
||||
const m: Mocha = new LocalMocha({ ignoreLeaks: false });
|
||||
}
|
||||
|
||||
function test_constructor_grep_string_option() {
|
||||
const m: Mocha = new LocalMocha({ grep: "describe" });
|
||||
}
|
||||
@ -885,6 +870,14 @@ function test_constructor_grep_regex_literal_option() {
|
||||
const m: Mocha = new LocalMocha({ grep: /(expect|should)/i });
|
||||
}
|
||||
|
||||
function test_constructor_parallel_option() {
|
||||
const m: Mocha = new LocalMocha({ parallel: true });
|
||||
}
|
||||
|
||||
function test_constructor_jobs_option() {
|
||||
const m: Mocha = new LocalMocha({ jobs: 4 });
|
||||
}
|
||||
|
||||
function test_constructor_all_options() {
|
||||
const m: Mocha = new LocalMocha({
|
||||
slow: 25,
|
||||
@ -893,8 +886,9 @@ function test_constructor_all_options() {
|
||||
globals: ['mocha'],
|
||||
reporter: 'html',
|
||||
bail: true,
|
||||
ignoreLeaks: true,
|
||||
grep: 'test'
|
||||
grep: 'test',
|
||||
parallel: true,
|
||||
jobs: 4
|
||||
});
|
||||
}
|
||||
|
||||
@ -958,16 +952,12 @@ function test_require_fluentParams() {
|
||||
.grep('[a-z]*')
|
||||
.grep(/[a-z]*/)
|
||||
.invert()
|
||||
.ignoreLeaks(true)
|
||||
.checkLeaks()
|
||||
.growl()
|
||||
.globals('foo')
|
||||
.globals(['bar', 'zap'])
|
||||
.useColors(true)
|
||||
.useInlineDiffs(true)
|
||||
.timeout(500)
|
||||
.slow(100)
|
||||
.enableTimeouts(true)
|
||||
.asyncOnly()
|
||||
.noHighlighting()
|
||||
.run();
|
||||
@ -1285,54 +1275,6 @@ function test_suite_events(suite: LocalMocha.Suite) {
|
||||
});
|
||||
}
|
||||
|
||||
function test_backcompat_Suite(suite: Mocha.Suite, iSuite: Mocha.ISuite, iSuiteContext: Mocha.ISuiteCallbackContext, iTest: Mocha.ITest, iContext: Mocha.IContext) {
|
||||
iSuite = suite;
|
||||
iSuiteContext = suite;
|
||||
suite.addTest(iTest);
|
||||
suite.addSuite(iSuite);
|
||||
LocalMocha.Suite.create(iSuite, string);
|
||||
new LocalMocha.Suite(string, iContext);
|
||||
}
|
||||
|
||||
function test_backcompat_Runner(runner: Mocha.Runner, iRunner: Mocha.IRunner, iSuite: Mocha.ISuite) {
|
||||
iRunner = runner;
|
||||
runner.grepTotal(iSuite);
|
||||
}
|
||||
|
||||
function test_backcompat_Runnable(runnable: Mocha.Runnable, iRunnable: Mocha.IRunnable) {
|
||||
iRunnable = runnable;
|
||||
}
|
||||
|
||||
function test_backcompat_Test(test: Mocha.Test, iTest: Mocha.ITest) {
|
||||
iTest = test;
|
||||
}
|
||||
|
||||
function test_backcompat_Hook(hook: Mocha.Hook, iHook: Mocha.IHook) {
|
||||
iHook = hook;
|
||||
}
|
||||
|
||||
function test_backcompat_Context(context: Mocha.Context, iContext: Mocha.IContext,
|
||||
iHookContext: Mocha.IHookCallbackContext, iBeforeAfterContext: Mocha.IBeforeAndAfterContext,
|
||||
iTestContext: Mocha.ITestCallbackContext, iRunnable: Mocha.IRunnable) {
|
||||
iContext = context;
|
||||
iHookContext = context;
|
||||
iBeforeAfterContext = context;
|
||||
iTestContext = context;
|
||||
context.runnable(iRunnable);
|
||||
}
|
||||
|
||||
function test_backcompat_Base(iRunner: Mocha.IRunner) {
|
||||
new LocalMocha.reporters.Base(iRunner);
|
||||
}
|
||||
|
||||
function test_backcompat_XUnit(iRunner: Mocha.IRunner) {
|
||||
new LocalMocha.reporters.XUnit(iRunner);
|
||||
}
|
||||
|
||||
function test_backcompat_Progress(iRunner: Mocha.IRunner) {
|
||||
new LocalMocha.reporters.Progress(iRunner);
|
||||
}
|
||||
|
||||
import common = require("mocha/lib/interfaces/common");
|
||||
|
||||
function test_interfaces_common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, localMocha: Mocha,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user