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