1 | // Type definitions for QUnit v2.19.0
|
2 | // Project: https://qunitjs.com/
|
3 | // Definitions by: James Bracy <https://github.com/waratuman>
|
4 | // Mike North <https://github.com/mike-north>
|
5 | // Stefan Sechelmann <https://github.com/sechel>
|
6 | // Chris Krycho <https://github.com/chriskrycho>
|
7 | // Dan Freeman <https://github.com/dfreeman>
|
8 | // James C. Davis <https://github.com/jamescdavis>
|
9 | // Timo Tijhof <https://github.com/Krinkle>
|
10 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
11 |
|
12 | declare global {
|
13 | interface Assert {
|
14 | /**
|
15 | * Instruct QUnit to wait for an asynchronous operation.
|
16 | *
|
17 | * `assert.async()` returns a callback function and pauses test processing until the
|
18 | * callback function is called. The callback will throw an `Error` if it is invoked more
|
19 | * often than the required call count.
|
20 | *
|
21 | * @param {number} [count=1] Number of expected calls
|
22 | */
|
23 | async(count?: number): () => void;
|
24 |
|
25 | /**
|
26 | * A recursive and strict comparison, considering all own and inherited properties.
|
27 | *
|
28 | * For primitive values, a strict comparison is used. For objects, the object identity is
|
29 | * disregarded and instead a recursive comparison of all own and inherited properties is
|
30 | * performed. This means arrays, plain objects, and arbitrary class instance objects can
|
31 | * all be compared in this way.
|
32 | *
|
33 | * The deep comparison includes built-in support for Date objects, regular expressions,
|
34 | * NaN, as well as ES6 features such as Symbol, Set, and Map objects.
|
35 | *
|
36 | * To assert strict equality on own properties only, refer to `assert.propEqual()`.
|
37 | *
|
38 | * @param actual Expression being tested
|
39 | * @param expected Known comparision value
|
40 | * @param {string} [message] Short description of the actual expression
|
41 | */
|
42 | deepEqual<T>(actual: T, expected: T, message?: string): void;
|
43 |
|
44 | /**
|
45 | * A non-strict comparison of two values.
|
46 | *
|
47 | * The `equal` assertion uses the simple comparison operator (`==`) to compare the actual
|
48 | * and expected arguments. When they are equal, the assertion passes; otherwise, it fails.
|
49 | *
|
50 | * When it fails, both actual and expected values are displayed in the test result, in
|
51 | * addition to a given message.
|
52 | *
|
53 | * To test for strict equality, use `assert.strictEqual()`.
|
54 | *
|
55 | * @param actual Expression being tested
|
56 | * @param expected Known comparison value
|
57 | * @param {string} [message] Short description of the actual expression
|
58 | */
|
59 | equal(actual: any, expected: any, message?: string): void;
|
60 |
|
61 | /**
|
62 | * Specify how many assertions are expected in a test.
|
63 | *
|
64 | * This is most commonly used as `assert.expect(0)`, which indicates that a test may pass
|
65 | * without making any assertions. This means the test is only used to verify that the code
|
66 | * runs to completion, without any uncaught errors. This is is essentially the inverse of
|
67 | * `assert.throws()`.
|
68 | *
|
69 | * This can also be used to explicitly require a certain number of assertions to be
|
70 | * recorded in a given test. If afterwards the number of assertions does not match the
|
71 | * expected count, the test will fail.
|
72 | *
|
73 | * It is recommended to test asynchronous code with `assert.step()` or `assert.async()`
|
74 | * instead.
|
75 | *
|
76 | * @param {number} amount Number of expected assertions in this test
|
77 | */
|
78 | expect(amount: number): void;
|
79 |
|
80 | /**
|
81 | * A strict comparison that passes if the first argument is boolean `false`.
|
82 | *
|
83 | * If the argument evaluates to false, the assertion passes; otherwise, it fails.
|
84 | *
|
85 | * @param state Expression being tested
|
86 | * @param {string} [message] Short description
|
87 | */
|
88 | false(state: any, message?: string): void;
|
89 |
|
90 | /**
|
91 | * An inverted deep equal comparison.
|
92 | *
|
93 | * This assertion fails if the actual and expected values are recursively equal by strict
|
94 | * comparison, considering both own and inherited properties.
|
95 | *
|
96 | * The assertion passes if there are structural differences, type differences, or even a
|
97 | * subtle difference in a particular property value.
|
98 | *
|
99 | * This is the inverse of `assert.deepEqual()`.
|
100 | *
|
101 | * @param actual Expression being tested
|
102 | * @param expected Known comparison value
|
103 | * @param {string} [message] Short description
|
104 | */
|
105 | notDeepEqual(actual: any, expected: any, message?: string): void;
|
106 |
|
107 | /**
|
108 | * A loose inequality comparison, checking for non-strict differences between two values.
|
109 | *
|
110 | * The `notEqual` assertion uses the simple inverted comparison operator (`!=`) to compare
|
111 | * the actual and expected values. When they aren't equal, the assertion passes;
|
112 | * otherwise, it fails. When it fails, both actual and expected values are displayed in
|
113 | * the test result, in addition to a given message.
|
114 | *
|
115 | * @param actual Expression being tested
|
116 | * @param expected Known comparison value
|
117 | * @param {string} [message] Short description
|
118 | */
|
119 | notEqual(actual: any, expected: any, message?: string): void;
|
120 |
|
121 | /**
|
122 | * A boolean check that passes when the first argument is falsy.
|
123 | *
|
124 | * If the argument evaluates to false, the assertion passes; otherwise, it fails.
|
125 | *
|
126 | * To strictly compare against boolean false, use `assert.false()`.
|
127 | *
|
128 | * @param state Expression being tested
|
129 | * @param {string} [message] Short description
|
130 | */
|
131 | notOk(state: any, message?: string): void;
|
132 |
|
133 | /**
|
134 | * Check that an object does not contain certain properties.
|
135 | *
|
136 | * The `notPropContains` assertion compares the subset of properties
|
137 | * in the expected object, and tests that these keys are either absent
|
138 | * or hold a value that is different according to a strict equality comparison.
|
139 | *
|
140 | * This method is recursive and allows partial comparison of nested objects as well.
|
141 | *
|
142 | * @param actual Expression being tested
|
143 | * @param expected Known comparison value
|
144 | * @param {string} [message] Short description
|
145 | */
|
146 | notPropContains(actual: any, expected: any, message?: string): void;
|
147 |
|
148 | /**
|
149 | * Compare an object's own properties using a strict inequality comparison.
|
150 | *
|
151 | * The `notPropEqual` assertion compares only an object's own properties,
|
152 | * using the strict inquality operator (`!==`).
|
153 | *
|
154 | * The test passes if there are properties with different values, or extra properties
|
155 | * or missing properties.
|
156 | *
|
157 | * @param actual Expression being tested
|
158 | * @param expected Known comparison value
|
159 | * @param {string} [message] Short description
|
160 | */
|
161 | notPropEqual(actual: any, expected: any, message?: string): void;
|
162 |
|
163 | /**
|
164 | * A strict comparison, checking for inequality.
|
165 | *
|
166 | * The `notStrictEqual` assertion uses the strict inverted comparison
|
167 | * operator (`!==`) to compare the actual and expected arguments. When they
|
168 | * aren't equal, the assertion passes; otherwise, it fails. When it fails,
|
169 | * both actual and expected values are displayed in the test result, in
|
170 | * addition to a given message.
|
171 | *
|
172 | * `assert.equal()` can be used to test equality.
|
173 | *
|
174 | * `assert.strictEqual()` can be used to test strict equality.
|
175 | *
|
176 | * @param actual Expression being tested
|
177 | * @param expected Known comparison value
|
178 | * @param {string} [message] Short description
|
179 | */
|
180 | notStrictEqual(actual: any, expected: any, message?: string): void;
|
181 |
|
182 | /**
|
183 | * A boolean check that passes when the first argument is truthy.
|
184 | *
|
185 | * If the argument evaluates to true, the assertion passes; otherwise, it fails.
|
186 | *
|
187 | * To strictly compare against boolean true, use `assert.true()`.
|
188 | *
|
189 | * @param state Expression being tested
|
190 | * @param {string} [message] Short description
|
191 | */
|
192 | ok(state: any, message?: string): void;
|
193 |
|
194 | /**
|
195 | * Check that an object contains certain properties.
|
196 | *
|
197 | * The `propContains` assertion compares only the subset of properties
|
198 | * in the expected object, and tests that these keys exist as own properties
|
199 | * with strictly equal values.
|
200 | *
|
201 | * This method is recursive and allows partial comparison of nested objects as well.
|
202 | *
|
203 | * Use `assert.propEqual()` to compare all properties.
|
204 | * Use `assert.notPropContains()` to test for the absence or inequality of properties.
|
205 | *
|
206 | * @param actual Expression being tested
|
207 | * @param expected Known comparison value
|
208 | * @param {string} [message] Short description of the actual expression
|
209 | */
|
210 | propContains(actual: any, expected: any, message?: string): void;
|
211 |
|
212 | /**
|
213 | * Compare an object's own properties using a strict comparison.
|
214 | *
|
215 | * The `propEqual` assertion only compares an object's own properties. This means the
|
216 | * expected value does not need to be an instance of the same class or otherwise inherit
|
217 | * the same prototype. This is in contrast with `assert.deepEqual()`.
|
218 | *
|
219 | * This assertion fails if the values differ, or if there are extra properties, or if
|
220 | * some properties are missing.
|
221 | *
|
222 | * This method is recursive and can compare any nested or complex object via a plain object.
|
223 | *
|
224 | * Use `assert.propContains()` to only check a subset of properties.
|
225 | *
|
226 | * @param actual Expression being tested
|
227 | * @param expected Known comparison value
|
228 | * @param {string} [message] Short description of the actual expression
|
229 | */
|
230 | propEqual(actual: any, expected: any, message?: string): void;
|
231 |
|
232 | /**
|
233 | * Report the result of a custom assertion.
|
234 | *
|
235 | * If you need to express an expectation that is not abstracted by a built-in assertion,
|
236 | * you can perform your own logic ad-hoc in an expression, and then pass two directly
|
237 | * comparable values top `assert.strictEqual()` or `assert.true()`.
|
238 | *
|
239 | * If you opt to create your own assertion method instead, use `pushResult` to
|
240 | * save the result.
|
241 | *
|
242 | * Example:
|
243 | *
|
244 | * ```
|
245 | * QUnit.assert.between = function (actual, from, to, message) {
|
246 | * const isBetween = (actual >= from && actual <= to);
|
247 | *
|
248 | * this.pushResult({
|
249 | * result: isBetween,
|
250 | * actual: actual,
|
251 | * expected: `between ${from} and ${to} inclusive`,
|
252 | * message: message
|
253 | * });
|
254 | * };
|
255 | * ```
|
256 | *
|
257 | * @param assertionResult The assertion result
|
258 | */
|
259 | pushResult(assertResult: { result: boolean; actual: any; expected: any; message?: string | undefined; source?: string | undefined }): void;
|
260 |
|
261 | /**
|
262 | * Test if the provided promise rejects, and optionally compare the rejection value.
|
263 | *
|
264 | * When testing code that is expected to return a rejected promise based on a
|
265 | * specific set of circumstances, use `assert.rejects()` for testing and comparison.
|
266 | *
|
267 | * The expectedMatcher argument can be:
|
268 | * A function that returns true when the assertion should be considered passing.
|
269 | * An Error object.
|
270 | * A base constructor to use ala rejectionValue instanceof expectedMatcher.
|
271 | * A RegExp that matches (or partially matches) rejectionValue.toString().
|
272 | *
|
273 | * Note: in order to avoid confusion between the message and the expectedMatcher,
|
274 | * the expectedMatcher can not be a string.
|
275 | *
|
276 | * @param promise Promise to test for rejection
|
277 | * @param expectedMatcher Rejection value matcher
|
278 | * @param message Short description of the assertion
|
279 | */
|
280 | rejects(promise: Promise<any>, message?: string): Promise<void>;
|
281 | rejects(promise: Promise<any>, expectedMatcher?: any, message?: string): Promise<void>;
|
282 |
|
283 | /**
|
284 | * Set how long to wait for async operations to finish.
|
285 | *
|
286 | * This assertion defines how long to wait (at most) in the current test. It overrides QUnit.config.testTimeout on a per-test basis.
|
287 | *
|
288 | * The timeout length only applies when a test actually involves asynchronous functions or promises. If 0 is passed, then awaiting or returning any Promise may fail the test.
|
289 | *
|
290 | * If assert.timeout() is called after a different timeout is already set, the old timeout will be cleared and the new duration will be used to start a new timer.
|
291 | *
|
292 | * @param duration The length of time to wait, in milleseconds.
|
293 | */
|
294 | timeout(duration: number): void;
|
295 |
|
296 | /**
|
297 | * Record a step for later verification.
|
298 | *
|
299 | * This assertion registers a passing assertion with the provided string. This and any
|
300 | * other steps should be verified later in the test via `assert.verifySteps()`.
|
301 | *
|
302 | * @param value Relevant string value, or short description, to mark this step.
|
303 | */
|
304 | step(value: string): void;
|
305 |
|
306 | /**
|
307 | * A strict type and value comparison.
|
308 | *
|
309 | * The `strictEqual()` assertion provides the most rigid comparison of type
|
310 | * and value with the strict equality operator (`===`).
|
311 | *
|
312 | * `assert.equal()` can be used to test non-strict equality.
|
313 | *
|
314 | * @param actual Expression being tested
|
315 | * @param expected Known comparison value
|
316 | * @param {string} [message] Short description of the assertion
|
317 | */
|
318 | strictEqual<T>(actual: T, expected: T, message?: string): void;
|
319 |
|
320 | /**
|
321 | * Test if a callback throws an exception, and optionally compare the thrown error.
|
322 | *
|
323 | * When testing code that is expected to throw an exception based on a
|
324 | * specific set of circumstances, use `assert.throws()` to catch the error
|
325 | * object for testing and comparison.
|
326 | *
|
327 | * The expectedMatcher argument can be:
|
328 | * An Error object.
|
329 | * An Error constructor to use ala `errorValue instanceof expectedMatcher`.
|
330 | * A RegExp that matches (or partially matches) the string representation.
|
331 | * A callback Function that must return `true` to pass the assertion check.
|
332 | */
|
333 | throws(block: () => void, expected?: any, message?: any): void;
|
334 | raises(block: () => void, expected?: any, message?: any): void;
|
335 |
|
336 | /**
|
337 | * A strict comparison that passes if the first argument is boolean `true`.
|
338 | *
|
339 | * If the argument evaluates to true, the assertion passes; otherwise, it fails.
|
340 | *
|
341 | * @param state Expression being tested
|
342 | * @param {string} [message] Short description of the actual expression
|
343 | */
|
344 | true(state: any, message?: string): void;
|
345 |
|
346 | /**
|
347 | * Verify the presence and exact order of previously marked steps in a test.
|
348 | *
|
349 | * The Step API provides an easy way to verify execution logic to a high degree of
|
350 | * accuracy and precision, whether for asynchronous code, event-driven code, or
|
351 | * callback-driven code.
|
352 | *
|
353 | * For example, you can mark steps to observe and validate whether parts of your code are
|
354 | * reached correctly, or to check the frequency (how often) an asynchronous code path is
|
355 | * executed. You can also capture any unexpected steps, which are automatically detected
|
356 | * and shown as part of the test failure.
|
357 | *
|
358 | * This assertion compares a given array of string values to a list of previously recorded
|
359 | * steps, as marked via previous calls to `assert.step()`.
|
360 | *
|
361 | * @param steps List of strings
|
362 | * @param message Short description of the assertion
|
363 | */
|
364 | verifySteps(steps: string[], message?: string): void;
|
365 | }
|
366 |
|
367 | interface Config {
|
368 | altertitle: boolean;
|
369 | autostart: boolean;
|
370 | collapse: boolean;
|
371 | current: any;
|
372 | failOnZeroTests: boolean;
|
373 | filter: string | RegExp;
|
374 | fixture: string;
|
375 | hidepassed: boolean;
|
376 | maxDepth: number;
|
377 | module: string;
|
378 | moduleId: string[];
|
379 | noglobals: boolean;
|
380 | notrycatch: boolean;
|
381 | reorder: boolean;
|
382 | requireExpects: boolean;
|
383 | scrolltop: boolean;
|
384 | seed: string;
|
385 | testId: string[];
|
386 | testTimeout?: number | null;
|
387 | urlConfig: {
|
388 | id?: string | undefined;
|
389 | label?: string | undefined;
|
390 | tooltip?: string | undefined;
|
391 | value?: string | string[] | { [key: string]: string } | undefined;
|
392 | }[];
|
393 | }
|
394 |
|
395 | interface GlobalHooks {
|
396 | /**
|
397 | * Runs after each test.
|
398 | */
|
399 | afterEach(fn: (assert: Assert) => void | Promise<void>): void;
|
400 |
|
401 | /**
|
402 | * Runs before each test.
|
403 | */
|
404 | beforeEach(fn: (assert: Assert) => void | Promise<void>): void;
|
405 | }
|
406 |
|
407 | interface Hooks {
|
408 | /**
|
409 | * Runs after the last test. If additional tests are defined after the
|
410 | * module's queue has emptied, it will not run this hook again.
|
411 | */
|
412 | after?: ((assert: Assert) => void | Promise<void>) | undefined;
|
413 |
|
414 | /**
|
415 | * Runs after each test.
|
416 | */
|
417 | afterEach?: ((assert: Assert) => void | Promise<void>) | undefined;
|
418 |
|
419 | /**
|
420 | * Runs before the first test.
|
421 | */
|
422 | before?: ((assert: Assert) => void | Promise<void>) | undefined;
|
423 |
|
424 | /**
|
425 | * Runs before each test.
|
426 | */
|
427 | beforeEach?: ((assert: Assert) => void | Promise<void>) | undefined;
|
428 | }
|
429 |
|
430 | interface NestedHooks {
|
431 | /**
|
432 | * Runs after the last test. If additional tests are defined after the
|
433 | * module's queue has emptied, it will not run this hook again.
|
434 | */
|
435 | after(fn: (assert: Assert) => void | Promise<void>): void;
|
436 |
|
437 | /**
|
438 | * Runs after each test.
|
439 | */
|
440 | afterEach(fn: (assert: Assert) => void | Promise<void>): void;
|
441 |
|
442 | /**
|
443 | * Runs before the first test.
|
444 | */
|
445 | before(fn: (assert: Assert) => void | Promise<void>): void;
|
446 |
|
447 | /**
|
448 | * Runs before each test.
|
449 | */
|
450 | beforeEach(fn: (assert: Assert) => void | Promise<void>): void;
|
451 | }
|
452 |
|
453 | type moduleFunc1 = (name: string, hooks?: Hooks, nested?: (hooks: NestedHooks) => void) => void;
|
454 | type moduleFunc2 = (name: string, nested?: (hooks: NestedHooks) => void) => void;
|
455 | type ModuleOnly = { only: moduleFunc1 & moduleFunc2 };
|
456 | type ModuleSkip = { skip: moduleFunc1 & moduleFunc2 };
|
457 | type ModuleTodo = { todo: moduleFunc1 & moduleFunc2 };
|
458 |
|
459 | namespace QUnit {
|
460 | interface BeginDetails {
|
461 | /** Number of registered tests */
|
462 | totalTests: number;
|
463 | /** List of registered modules, */
|
464 | modules: Array<{ name: string, moduleId: string }>
|
465 | }
|
466 | interface DoneDetails {
|
467 | failed: number;
|
468 | passed: number;
|
469 | total: number;
|
470 | runtime: number;
|
471 | }
|
472 | interface LogDetails {
|
473 | result: boolean;
|
474 | actual: any;
|
475 | expected: any;
|
476 | message: string;
|
477 | source: string;
|
478 | module: string;
|
479 | name: string;
|
480 | runtime: number;
|
481 | }
|
482 | interface ModuleDoneDetails {
|
483 | name: string;
|
484 | failed: number;
|
485 | passed: number;
|
486 | total: number;
|
487 | runtime: number;
|
488 | }
|
489 | interface ModuleStartDetails {
|
490 | name: string;
|
491 | }
|
492 | interface TestDoneDetails {
|
493 | name: string;
|
494 | module: string;
|
495 | failed: number;
|
496 | passed: number;
|
497 | total: number;
|
498 | runtime: number;
|
499 | }
|
500 | interface TestStartDetails {
|
501 | name: string;
|
502 | module: string;
|
503 | }
|
504 |
|
505 | interface Module {
|
506 | name: string;
|
507 | // tests: Array<{ name: string; id: string; skip: boolean }>;
|
508 | // childModules: Module[];
|
509 | // testsRun: number;
|
510 | // testsIgnored: number;
|
511 | // hooks: Hooks;
|
512 | // skip?: boolean;
|
513 | // ignored?: boolean;
|
514 | }
|
515 |
|
516 | interface TestBase {
|
517 | testId: string;
|
518 | testName: string;
|
519 | expected: null | number;
|
520 | // assertions: Array<{ result: boolean; message: string }>;
|
521 | module: Module;
|
522 | // steps: unknown[];
|
523 | // timeout: undefined;
|
524 | // data: unknown;
|
525 | // withData: boolean;
|
526 | // pauses: Map<string, unknown>;
|
527 | // nextPauseId: 1;
|
528 | // stackOffset: 0 | 1 | 2 | 3 | 5;
|
529 | // errorForStack: Error;
|
530 | // testReport: unknown;
|
531 | // stack: string;
|
532 | // before: () => unknown;
|
533 | // run: () => unknown;
|
534 | // after: () => void;
|
535 | // queueGlobalHook: (hook: unknown, hookName: unknown) => () => unknown;
|
536 | // queueHook: (
|
537 | // hook: unknown,
|
538 | // hookName: unknown,
|
539 | // hookOwner: unknown
|
540 | // ) => () => unknown;
|
541 | // hooks: (handler: unknown) => unknown;
|
542 | finish: () => unknown;
|
543 | // preserveTestEnvironment: () => unknown;
|
544 | // queue: () => void;
|
545 | // pushResult: (resultInfo: unknown) => void;
|
546 | pushFailure: (message: string, source: string, actual: unknown) => void;
|
547 | skip?: true;
|
548 | // callback: ((assert: Assert) => void) | ((assert: Assert) => Promise<void>);
|
549 | todo?: boolean;
|
550 | async?: boolean;
|
551 | }
|
552 |
|
553 | interface AssertionTest extends TestBase {
|
554 | assert: Assert;
|
555 | }
|
556 |
|
557 | interface SkipTest extends TestBase {
|
558 | skip: true;
|
559 | async: false;
|
560 | }
|
561 |
|
562 | interface TodoTest extends TestBase {
|
563 | todo: true;
|
564 | assert: Assert;
|
565 | }
|
566 |
|
567 | type Test = AssertionTest | SkipTest | TodoTest;
|
568 | }
|
569 |
|
570 | interface QUnit {
|
571 | /**
|
572 | * Namespace for QUnit assertions
|
573 | *
|
574 | * QUnit's built-in assertions are defined on the `QUnit.assert` object. An
|
575 | * instance of this object is passed as the only argument to the `QUnit.test`
|
576 | * function callback.
|
577 | *
|
578 | * This object has properties for each of QUnit's built-in assertion methods.
|
579 | */
|
580 | assert: Assert;
|
581 |
|
582 | /**
|
583 | * Register a callback to fire whenever the test suite begins.
|
584 | *
|
585 | * `QUnit.begin()` is called once before running any tests.
|
586 | *
|
587 | * callback Callback to execute.
|
588 | */
|
589 | begin(callback: (details: QUnit.BeginDetails) => void | Promise<void>): void;
|
590 |
|
591 | /**
|
592 | * Configuration for QUnit
|
593 | *
|
594 | * QUnit has a bunch of internal configuration defaults, some of which are
|
595 | * useful to override. Check the description for each option for details.
|
596 | */
|
597 | config: Config;
|
598 |
|
599 | /**
|
600 | * Register a callback to fire whenever the test suite ends.
|
601 | *
|
602 | * @param callback Callback to execute
|
603 | */
|
604 | done(callback: (details: QUnit.DoneDetails) => void | Promise<void>): void;
|
605 |
|
606 | /**
|
607 | * Advanced and extensible data dumping for JavaScript.
|
608 | *
|
609 | * This method does string serialization by parsing data structures and
|
610 | * objects. It parses DOM elements to a string representation of their outer
|
611 | * HTML. By default, nested structures will be displayed up to five levels
|
612 | * deep. Anything beyond that is replaced by `[object Object]` and
|
613 | * `[object Array]` placeholders.
|
614 | *
|
615 | * If you need more or less output, change the value of `QUnit.dump.maxDepth`,
|
616 | * representing how deep the elements should be parsed.
|
617 | *
|
618 | * Note: This method used to be in QUnit.jsDump, which was changed to
|
619 | * QUnit.dump. The old property will be removed in QUnit 3.0.
|
620 | */
|
621 | dump: {
|
622 | maxDepth: number;
|
623 | parse(data: any): string;
|
624 | };
|
625 |
|
626 | /**
|
627 | * Copy the properties defined by the `mixin` object into the `target` object.
|
628 | *
|
629 | * This method will modify the `target` object to contain the "own" properties
|
630 | * defined by the `mixin`. If the `mixin` object specifies the value of any
|
631 | * attribute as undefined, this property will instead be removed from the
|
632 | * `target` object.
|
633 | *
|
634 | * @param target An object whose properties are to be modified
|
635 | * @param mixin An object describing which properties should be modified
|
636 | */
|
637 | extend(target: any, mixin: any): void;
|
638 |
|
639 | /**
|
640 | * Register a global callback to run before or after each test.
|
641 | *
|
642 | * This is the equivalent of applying a QUnit.module() hook to all modules
|
643 | * and all tests, including global tests that are not associated with any module.
|
644 | *
|
645 | * Similar to module hooks, global hooks support async functions or
|
646 | * returning a Promise, which will be waited for before QUnit continues executing tests.
|
647 | * Each global hook also has access to the same assert object and
|
648 | * test context as the QUnit.test that the hook is running for.
|
649 | *
|
650 | * For more details about hooks, refer to QUnit.module § Hooks.
|
651 | */
|
652 | hooks: GlobalHooks
|
653 |
|
654 | /**
|
655 | * Register a callback to fire whenever an assertion completes.
|
656 | *
|
657 | * This is one of several callbacks QUnit provides. Its intended for
|
658 | * integration scenarios like PhantomJS or Jenkins. The properties of the
|
659 | * details argument are listed below as options.
|
660 | *
|
661 | * @param callback Callback to execute
|
662 | */
|
663 | log(callback: (details: QUnit.LogDetails) => void): void;
|
664 |
|
665 | /**
|
666 | * Group related tests under a single label.
|
667 | *
|
668 | * You can use the module name to organize, select, and filter tests to run.
|
669 | *
|
670 | * All tests inside a module callback function will be grouped into that
|
671 | * module. The test names will all be preceded by the module name in the
|
672 | * test results. Other modules can be nested inside this callback function,
|
673 | * where their tests' names will be labeled by their names recursively
|
674 | * prefixed by their parent modules.
|
675 | *
|
676 | * If `QUnit.module` is defined without a `nested` callback argument, all
|
677 | * subsequently defined tests will be grouped into the module until another
|
678 | * module is defined.
|
679 | *
|
680 | * Modules with test group functions allow you to define nested modules, and
|
681 | * QUnit will run tests on the parent module before going deep on the nested
|
682 | * ones, even if they're declared first. Additionally, any hook callbacks on
|
683 | * a parent module will wrap the hooks on a nested module. In other words,
|
684 | * `before` and `beforeEach` callbacks will form a queue while the
|
685 | * `afterEach` and `after` callbacks will form a stack.
|
686 | *
|
687 | * You can specify code to run before and after tests using the hooks
|
688 | * argument, and also to create properties that will be shared on the
|
689 | * testing context. Any additional properties on the `hooks` object will be
|
690 | * added to that context. The `hooks` argument is still optional if you call
|
691 | * `QUnit.module` with a callback argument.
|
692 | *
|
693 | * The module's callback is invoked with the test environment as its `this`
|
694 | * context, with the environment's properties copied to the module's tests,
|
695 | * hooks, and nested modules. Note that changes on tests' `this` are not
|
696 | * preserved between sibling tests, where `this` will be reset to the initial
|
697 | * value for each test.
|
698 | *
|
699 | * @param {string} name Label for this group of tests
|
700 | * @param hookds Callbacks to run during test execution
|
701 | * @param nested A callback with grouped tests and nested modules to run under the current module label
|
702 | */
|
703 | module: moduleFunc1 & moduleFunc2 & ModuleOnly & ModuleSkip & ModuleTodo;
|
704 |
|
705 | /**
|
706 | * Register a callback to fire whenever a module ends.
|
707 | *
|
708 | * @param callback Callback to execute
|
709 | */
|
710 | moduleDone(callback: (details: QUnit.ModuleDoneDetails) => void | Promise<void>): void;
|
711 |
|
712 | /**
|
713 | * Register a callback to fire whenever a module begins.
|
714 | *
|
715 | * @param callback Callback to execute
|
716 | */
|
717 | moduleStart(callback: (details: QUnit.ModuleStartDetails) => void | Promise<void>): void;
|
718 |
|
719 | /**
|
720 | * Adds a test to exclusively run, preventing all other tests from running.
|
721 | *
|
722 | * Use this method to focus your test suite on a specific test. QUnit.only
|
723 | * will cause any other tests in your suite to be ignored.
|
724 | *
|
725 | * Note, that if more than one QUnit.only is present only the first instance
|
726 | * will run.
|
727 | *
|
728 | * This is an alternative to filtering tests to run in the HTML reporter. It
|
729 | * is especially useful when you use a console reporter or in a codebase
|
730 | * with a large set of long running tests.
|
731 | *
|
732 | * @param {string} name Title of unit being tested
|
733 | * Function to close over assertions
callback |
734 | */
|
735 | only(name: string, callback: (assert: Assert) => void | Promise<void>): void;
|
736 |
|
737 | /**
|
738 | * Handle a global error that should result in a failed test run.
|
739 | *
|
740 | * @since 2.17.0
|
741 | * @param {Error|any} error
|
742 | */
|
743 | onUncaughtException: (error: unknown) => void;
|
744 |
|
745 | /**
|
746 | * DEPRECATED: Report the result of a custom assertion.
|
747 | *
|
748 | * This method is deprecated and it's recommended to use pushResult on its
|
749 | * direct reference in the assertion context.
|
750 | *
|
751 | * QUnit.push reflects to the current running test, and it may leak
|
752 | * assertions in asynchronous mode. Checkout assert.pushResult() to set a
|
753 | * proper custom assertion.
|
754 | *
|
755 | * Invoking QUnit.push allows to create a readable expectation that is not
|
756 | * defined by any of QUnit's built-in assertions.
|
757 | *
|
758 | * @deprecated
|
759 | */
|
760 | push(result: boolean, actual: any, expected: any, message: string): void;
|
761 |
|
762 | /**
|
763 | * Adds a test like object to be skipped.
|
764 | *
|
765 | * Use this method to replace QUnit.test() instead of commenting out entire
|
766 | * tests.
|
767 | *
|
768 | * This test's prototype will be listed on the suite as a skipped test,
|
769 | * ignoring the callback argument and the respective global and module's
|
770 | * hooks.
|
771 | *
|
772 | * @param {string} Title of unit being tested
|
773 | */
|
774 | skip(name: string, callback?: (assert: Assert) => void | Promise<void>): void;
|
775 |
|
776 | /**
|
777 | * Returns a single line string representing the stacktrace (call stack).
|
778 | *
|
779 | * This method returns a single line string representing the stacktrace from
|
780 | * where it was called. According to its offset argument, `QUnit.stack()` will
|
781 | * return the correspondent line from the call stack.
|
782 | *
|
783 | * The default `offset` is `0` and will return the current location where it
|
784 | * was called.
|
785 | *
|
786 | * Not all browsers support retrieving stracktraces. In those, `QUnit.stack()`
|
787 | * will return undefined.
|
788 | *
|
789 | * @param {number} offset Set the stacktrace line offset.
|
790 | */
|
791 | stack(offset?: number): string;
|
792 |
|
793 | /**
|
794 | * `QUnit.start()` must be used to start a test run that has
|
795 | * `QUnit.config.autostart` set to `false`.
|
796 | *
|
797 | * This method was previously used to control async tests on text contexts
|
798 | * along with QUnit.stop. For asynchronous tests, use assert.async instead.
|
799 | *
|
800 | * When your async test has multiple exit points, call `QUnit.start()` for the
|
801 | * corresponding number of `QUnit.stop()` increments.
|
802 | */
|
803 | start(): void;
|
804 |
|
805 | /**
|
806 | * Add a test to run.
|
807 | *
|
808 | * Add a test to run using `QUnit.test()`.
|
809 | *
|
810 | * The `assert` argument to the callback contains all of QUnit's assertion
|
811 | * methods. Use this argument to call your test assertions.
|
812 | *
|
813 | * `QUnit.test()` can automatically handle the asynchronous resolution of a
|
814 | * Promise on your behalf if you return a thenable Promise as the result of
|
815 | * your callback function.
|
816 | *
|
817 | * @param {string} Title of unit being tested
|
818 | * @param callback Function to close over assertions
|
819 | */
|
820 | test(name: string, callback: (assert: Assert) => void | Promise<void>): void;
|
821 |
|
822 | /**
|
823 | * Register a callback to fire whenever a test ends.
|
824 | *
|
825 | * @param callback Callback to execute
|
826 | */
|
827 | testDone(
|
828 | callback: (details: {
|
829 | name: string;
|
830 | module: string;
|
831 | failed: number;
|
832 | passed: number;
|
833 | total: number;
|
834 | runtime: number;
|
835 | }) => void | Promise<void>,
|
836 | ): void;
|
837 |
|
838 | /**
|
839 | * Register a callback to fire whenever a test begins.
|
840 | *
|
841 | * @param callback Callback to execute
|
842 | */
|
843 | testStart(callback: (details: QUnit.TestStartDetails) => void | Promise<void>): void;
|
844 |
|
845 | /**
|
846 | * Adds a test which expects at least one failing assertion during its run.
|
847 | *
|
848 | * Use this method to test a unit of code which is still under development
|
849 | * (in a “todo” state). The test will pass as long as one failing assertion
|
850 | * is present.
|
851 | *
|
852 | * If all assertions pass, then the test will fail signaling that QUnit.todo
|
853 | * should be replaced by QUnit.test.
|
854 | *
|
855 | * @param {string} Title of unit being tested
|
856 | * Function to close over assertions
callback |
857 | */
|
858 | todo(name: string, callback?: (assert: Assert) => void | Promise<void>): void;
|
859 |
|
860 | /**
|
861 | * Compares two values. Returns true if they are equivalent.
|
862 | *
|
863 | * @param a The first value
|
864 | * @param b The second value
|
865 | */
|
866 | equiv<T>(a: T, b: T): boolean;
|
867 |
|
868 | /**
|
869 | * Are the test running from the server or not.
|
870 | */
|
871 | isLocal: boolean;
|
872 |
|
873 | /**
|
874 | * QUnit version
|
875 | */
|
876 | version: string;
|
877 |
|
878 | urlParams: Record<string, unknown>;
|
879 | }
|
880 |
|
881 | /* QUnit */
|
882 | const QUnit: QUnit;
|
883 | }
|
884 |
|
885 | export = QUnit;
|