1+ // Generated by typings
2+ // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/b1daff0be8fa53f645365303d8e0145d055370e9/mocha/mocha.d.ts
3+ interface MochaSetupOptions {
4+ //milliseconds to wait before considering a test slow
5+ slow ?: number ;
6+
7+ // timeout in milliseconds
8+ timeout ?: number ;
9+
10+ // ui name "bdd", "tdd", "exports" etc
11+ ui ?: string ;
12+
13+ //array of accepted globals
14+ globals ?: any [ ] ;
15+
16+ // reporter instance (function or string), defaults to `mocha.reporters.Spec`
17+ reporter ?: any ;
18+
19+ // bail on the first test failure
20+ bail ?: boolean ;
21+
22+ // ignore global leaks
23+ ignoreLeaks ?: boolean ;
24+
25+ // grep string or regexp to filter tests with
26+ grep ?: any ;
27+ }
28+
29+ interface MochaDone {
30+ ( error ?: Error ) : void ;
31+ }
32+
33+ declare var mocha : Mocha ;
34+ declare var describe : Mocha . IContextDefinition ;
35+ declare var xdescribe : Mocha . IContextDefinition ;
36+ // alias for `describe`
37+ declare var context : Mocha . IContextDefinition ;
38+ // alias for `describe`
39+ declare var suite : Mocha . IContextDefinition ;
40+ declare var it : Mocha . ITestDefinition ;
41+ declare var xit : Mocha . ITestDefinition ;
42+ // alias for `it`
43+ declare var test : Mocha . ITestDefinition ;
44+ declare var specify : Mocha . ITestDefinition ;
45+
46+ declare function before ( action : ( ) => void ) : void ;
47+
48+ declare function before ( action : ( done : MochaDone ) => void ) : void ;
49+
50+ declare function before ( description : string , action : ( ) => void ) : void ;
51+
52+ declare function before ( description : string , action : ( done : MochaDone ) => void ) : void ;
53+
54+ declare function setup ( action : ( ) => void ) : void ;
55+
56+ declare function setup ( action : ( done : MochaDone ) => void ) : void ;
57+
58+ declare function after ( action : ( ) => void ) : void ;
59+
60+ declare function after ( action : ( done : MochaDone ) => void ) : void ;
61+
62+ declare function after ( description : string , action : ( ) => void ) : void ;
63+
64+ declare function after ( description : string , action : ( done : MochaDone ) => void ) : void ;
65+
66+ declare function teardown ( action : ( ) => void ) : void ;
67+
68+ declare function teardown ( action : ( done : MochaDone ) => void ) : void ;
69+
70+ declare function beforeEach ( action : ( ) => void ) : void ;
71+
72+ declare function beforeEach ( action : ( done : MochaDone ) => void ) : void ;
73+
74+ declare function beforeEach ( description : string , action : ( ) => void ) : void ;
75+
76+ declare function beforeEach ( description : string , action : ( done : MochaDone ) => void ) : void ;
77+
78+ declare function suiteSetup ( action : ( ) => void ) : void ;
79+
80+ declare function suiteSetup ( action : ( done : MochaDone ) => void ) : void ;
81+
82+ declare function afterEach ( action : ( ) => void ) : void ;
83+
84+ declare function afterEach ( action : ( done : MochaDone ) => void ) : void ;
85+
86+ declare function afterEach ( description : string , action : ( ) => void ) : void ;
87+
88+ declare function afterEach ( description : string , action : ( done : MochaDone ) => void ) : void ;
89+
90+ declare function suiteTeardown ( action : ( ) => void ) : void ;
91+
92+ declare function suiteTeardown ( action : ( done : MochaDone ) => void ) : void ;
93+
94+ declare class Mocha {
95+ constructor ( options ?: {
96+ grep ?: RegExp ;
97+ ui ?: string ;
98+ reporter ?: string ;
99+ timeout ?: number ;
100+ bail ?: boolean ;
101+ } ) ;
102+
103+ /** Setup mocha with the given options. */
104+ setup ( options : MochaSetupOptions ) : Mocha ;
105+ bail ( value ?: boolean ) : Mocha ;
106+ addFile ( file : string ) : Mocha ;
107+ /** Sets reporter by name, defaults to "spec". */
108+ reporter ( name : string ) : Mocha ;
109+ /** Sets reporter constructor, defaults to mocha.reporters.Spec. */
110+ reporter ( reporter : ( runner : Mocha . IRunner , options : any ) => any ) : Mocha ;
111+ ui ( value : string ) : Mocha ;
112+ grep ( value : string ) : Mocha ;
113+ grep ( value : RegExp ) : Mocha ;
114+ invert ( ) : Mocha ;
115+ ignoreLeaks ( value : boolean ) : Mocha ;
116+ checkLeaks ( ) : Mocha ;
117+ /**
118+ * Function to allow assertion libraries to throw errors directly into mocha.
119+ * This is useful when running tests in a browser because window.onerror will
120+ * only receive the 'message' attribute of the Error.
121+ */
122+ throwError ( error : Error ) : void ;
123+ /** Enables growl support. */
124+ growl ( ) : Mocha ;
125+ globals ( value : string ) : Mocha ;
126+ globals ( values : string [ ] ) : Mocha ;
127+ useColors ( value : boolean ) : Mocha ;
128+ useInlineDiffs ( value : boolean ) : Mocha ;
129+ timeout ( value : number ) : Mocha ;
130+ slow ( value : number ) : Mocha ;
131+ enableTimeouts ( value : boolean ) : Mocha ;
132+ asyncOnly ( value : boolean ) : Mocha ;
133+ noHighlighting ( value : boolean ) : Mocha ;
134+ /** Runs tests and invokes `onComplete()` when finished. */
135+ run ( onComplete ?: ( failures : number ) => void ) : Mocha . IRunner ;
136+ }
137+
138+ // merge the Mocha class declaration with a module
139+ declare namespace Mocha {
140+ /** Partial interface for Mocha's `Runnable` class. */
141+ interface IRunnable {
142+ title : string ;
143+ fn : Function ;
144+ async : boolean ;
145+ sync : boolean ;
146+ timedOut : boolean ;
147+ }
148+
149+ /** Partial interface for Mocha's `Suite` class. */
150+ interface ISuite {
151+ parent : ISuite ;
152+ title : string ;
153+
154+ fullTitle ( ) : string ;
155+ }
156+
157+ /** Partial interface for Mocha's `Test` class. */
158+ interface ITest extends IRunnable {
159+ parent : ISuite ;
160+ pending : boolean ;
161+
162+ fullTitle ( ) : string ;
163+ }
164+
165+ /** Partial interface for Mocha's `Runner` class. */
166+ interface IRunner { }
167+
168+ interface IContextDefinition {
169+ ( description : string , spec : ( ) => void ) : ISuite ;
170+ only ( description : string , spec : ( ) => void ) : ISuite ;
171+ skip ( description : string , spec : ( ) => void ) : void ;
172+ timeout ( ms : number ) : void ;
173+ }
174+
175+ interface ITestDefinition {
176+ ( expectation : string , assertion ?: ( ) => void ) : ITest ;
177+ ( expectation : string , assertion ?: ( done : MochaDone ) => void ) : ITest ;
178+ only ( expectation : string , assertion ?: ( ) => void ) : ITest ;
179+ only ( expectation : string , assertion ?: ( done : MochaDone ) => void ) : ITest ;
180+ skip ( expectation : string , assertion ?: ( ) => void ) : void ;
181+ skip ( expectation : string , assertion ?: ( done : MochaDone ) => void ) : void ;
182+ timeout ( ms : number ) : void ;
183+ }
184+
185+ export module reporters {
186+ export class Base {
187+ stats : {
188+ suites : number ;
189+ tests : number ;
190+ passes : number ;
191+ pending : number ;
192+ failures : number ;
193+ } ;
194+
195+ constructor ( runner : IRunner ) ;
196+ }
197+
198+ export class Doc extends Base { }
199+ export class Dot extends Base { }
200+ export class HTML extends Base { }
201+ export class HTMLCov extends Base { }
202+ export class JSON extends Base { }
203+ export class JSONCov extends Base { }
204+ export class JSONStream extends Base { }
205+ export class Landing extends Base { }
206+ export class List extends Base { }
207+ export class Markdown extends Base { }
208+ export class Min extends Base { }
209+ export class Nyan extends Base { }
210+ export class Progress extends Base {
211+ /**
212+ * @param options.open String used to indicate the start of the progress bar.
213+ * @param options.complete String used to indicate a complete test on the progress bar.
214+ * @param options.incomplete String used to indicate an incomplete test on the progress bar.
215+ * @param options.close String used to indicate the end of the progress bar.
216+ */
217+ constructor ( runner : IRunner , options ?: {
218+ open ?: string ;
219+ complete ?: string ;
220+ incomplete ?: string ;
221+ close ?: string ;
222+ } ) ;
223+ }
224+ export class Spec extends Base { }
225+ export class TAP extends Base { }
226+ export class XUnit extends Base {
227+ constructor ( runner : IRunner , options ?: any ) ;
228+ }
229+ }
230+ }
231+
232+ declare module "mocha" {
233+ export = Mocha ;
234+ }
0 commit comments