UNPKG

33.5 kBTypeScriptView Raw
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
12declare 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 }): 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 filter: string | RegExp;
373 fixture: string;
374 hidepassed: boolean;
375 maxDepth: number;
376 module: string;
377 moduleId: string[];
378 notrycatch: boolean;
379 noglobals: boolean;
380 seed: string;
381 reorder: boolean;
382 requireExpects: boolean;
383 testId: string[];
384 testTimeout: number;
385 scrolltop: boolean;
386 urlConfig: {
387 id?: string | undefined;
388 label?: string | undefined;
389 tooltip?: string | undefined;
390 value?: string | string[] | { [key: string]: string } | undefined;
391 }[];
392 }
393
394 interface GlobalHooks {
395 /**
396 * Runs after each test.
397 */
398 afterEach(fn: (assert: Assert) => void | Promise<void>): void;
399
400 /**
401 * Runs before each test.
402 */
403 beforeEach(fn: (assert: Assert) => void | Promise<void>): void;
404 }
405
406 interface Hooks {
407 /**
408 * Runs after the last test. If additional tests are defined after the
409 * module's queue has emptied, it will not run this hook again.
410 */
411 after?: ((assert: Assert) => void | Promise<void>) | undefined;
412
413 /**
414 * Runs after each test.
415 */
416 afterEach?: ((assert: Assert) => void | Promise<void>) | undefined;
417
418 /**
419 * Runs before the first test.
420 */
421 before?: ((assert: Assert) => void | Promise<void>) | undefined;
422
423 /**
424 * Runs before each test.
425 */
426 beforeEach?: ((assert: Assert) => void | Promise<void>) | undefined;
427 }
428
429 interface NestedHooks {
430 /**
431 * Runs after the last test. If additional tests are defined after the
432 * module's queue has emptied, it will not run this hook again.
433 */
434 after(fn: (assert: Assert) => void | Promise<void>): void;
435
436 /**
437 * Runs after each test.
438 */
439 afterEach(fn: (assert: Assert) => void | Promise<void>): void;
440
441 /**
442 * Runs before the first test.
443 */
444 before(fn: (assert: Assert) => void | Promise<void>): void;
445
446 /**
447 * Runs before each test.
448 */
449 beforeEach(fn: (assert: Assert) => void | Promise<void>): void;
450 }
451
452 type moduleFunc1 = (name: string, hooks?: Hooks, nested?: (hooks: NestedHooks) => void) => void;
453 type moduleFunc2 = (name: string, nested?: (hooks: NestedHooks) => void) => void;
454 type ModuleOnly = { only: moduleFunc1 & moduleFunc2 };
455 type ModuleSkip = { skip: moduleFunc1 & moduleFunc2 };
456 type ModuleTodo = { todo: moduleFunc1 & moduleFunc2 };
457
458 namespace QUnit {
459 interface BeginDetails {
460 /** Number of registered tests */
461 totalTests: number;
462 /** List of registered modules, */
463 modules: Array<{ name: string, moduleId: string }>
464 }
465 interface DoneDetails {
466 failed: number;
467 passed: number;
468 total: number;
469 runtime: number;
470 }
471 interface LogDetails {
472 result: boolean;
473 actual: any;
474 expected: any;
475 message: string;
476 source: string;
477 module: string;
478 name: string;
479 runtime: number;
480 }
481 interface ModuleDoneDetails {
482 name: string;
483 failed: number;
484 passed: number;
485 total: number;
486 runtime: number;
487 }
488 interface ModuleStartDetails {
489 name: string;
490 }
491 interface TestDoneDetails {
492 name: string;
493 module: string;
494 failed: number;
495 passed: number;
496 total: number;
497 runtime: number;
498 }
499 interface TestStartDetails {
500 name: string;
501 module: string;
502 }
503 }
504
505 interface QUnit {
506 /**
507 * Namespace for QUnit assertions
508 *
509 * QUnit's built-in assertions are defined on the `QUnit.assert` object. An
510 * instance of this object is passed as the only argument to the `QUnit.test`
511 * function callback.
512 *
513 * This object has properties for each of QUnit's built-in assertion methods.
514 */
515 assert: Assert;
516
517 /**
518 * Register a callback to fire whenever the test suite begins.
519 *
520 * `QUnit.begin()` is called once before running any tests.
521 *
522 * @callback callback Callback to execute.
523 */
524 begin(callback: (details: QUnit.BeginDetails) => void | Promise<void>): void;
525
526 /**
527 * Configuration for QUnit
528 *
529 * QUnit has a bunch of internal configuration defaults, some of which are
530 * useful to override. Check the description for each option for details.
531 */
532 config: Config;
533
534 /**
535 * Register a callback to fire whenever the test suite ends.
536 *
537 * @param callback Callback to execute
538 */
539 done(callback: (details: QUnit.DoneDetails) => void | Promise<void>): void;
540
541 /**
542 * Advanced and extensible data dumping for JavaScript.
543 *
544 * This method does string serialization by parsing data structures and
545 * objects. It parses DOM elements to a string representation of their outer
546 * HTML. By default, nested structures will be displayed up to five levels
547 * deep. Anything beyond that is replaced by `[object Object]` and
548 * `[object Array]` placeholders.
549 *
550 * If you need more or less output, change the value of `QUnit.dump.maxDepth`,
551 * representing how deep the elements should be parsed.
552 *
553 * Note: This method used to be in QUnit.jsDump, which was changed to
554 * QUnit.dump. The old property will be removed in QUnit 3.0.
555 */
556 dump: {
557 maxDepth: number;
558 parse(data: any): string;
559 };
560
561 /**
562 * Copy the properties defined by the `mixin` object into the `target` object.
563 *
564 * This method will modify the `target` object to contain the "own" properties
565 * defined by the `mixin`. If the `mixin` object specifies the value of any
566 * attribute as undefined, this property will instead be removed from the
567 * `target` object.
568 *
569 * @param target An object whose properties are to be modified
570 * @param mixin An object describing which properties should be modified
571 */
572 extend(target: any, mixin: any): void;
573
574 /**
575 * Register a global callback to run before or after each test.
576 *
577 * This is the equivalent of applying a QUnit.module() hook to all modules
578 * and all tests, including global tests that are not associated with any module.
579 *
580 * Similar to module hooks, global hooks support async functions or
581 * returning a Promise, which will be waited for before QUnit continues executing tests.
582 * Each global hook also has access to the same assert object and
583 * test context as the QUnit.test that the hook is running for.
584 *
585 * For more details about hooks, refer to QUnit.module § Hooks.
586 */
587 hooks: GlobalHooks
588
589 /**
590 * Register a callback to fire whenever an assertion completes.
591 *
592 * This is one of several callbacks QUnit provides. Its intended for
593 * integration scenarios like PhantomJS or Jenkins. The properties of the
594 * details argument are listed below as options.
595 *
596 * @param callback Callback to execute
597 */
598 log(callback: (details: QUnit.LogDetails) => void): void;
599
600 /**
601 * Group related tests under a single label.
602 *
603 * You can use the module name to organize, select, and filter tests to run.
604 *
605 * All tests inside a module callback function will be grouped into that
606 * module. The test names will all be preceded by the module name in the
607 * test results. Other modules can be nested inside this callback function,
608 * where their tests' names will be labeled by their names recursively
609 * prefixed by their parent modules.
610 *
611 * If `QUnit.module` is defined without a `nested` callback argument, all
612 * subsequently defined tests will be grouped into the module until another
613 * module is defined.
614 *
615 * Modules with test group functions allow you to define nested modules, and
616 * QUnit will run tests on the parent module before going deep on the nested
617 * ones, even if they're declared first. Additionally, any hook callbacks on
618 * a parent module will wrap the hooks on a nested module. In other words,
619 * `before` and `beforeEach` callbacks will form a queue while the
620 * `afterEach` and `after` callbacks will form a stack.
621 *
622 * You can specify code to run before and after tests using the hooks
623 * argument, and also to create properties that will be shared on the
624 * testing context. Any additional properties on the `hooks` object will be
625 * added to that context. The `hooks` argument is still optional if you call
626 * `QUnit.module` with a callback argument.
627 *
628 * The module's callback is invoked with the test environment as its `this`
629 * context, with the environment's properties copied to the module's tests,
630 * hooks, and nested modules. Note that changes on tests' `this` are not
631 * preserved between sibling tests, where `this` will be reset to the initial
632 * value for each test.
633 *
634 * @param {string} name Label for this group of tests
635 * @param hookds Callbacks to run during test execution
636 * @param nested A callback with grouped tests and nested modules to run under the current module label
637 */
638 module: moduleFunc1 & moduleFunc2 & ModuleOnly & ModuleSkip & ModuleTodo;
639
640 /**
641 * Register a callback to fire whenever a module ends.
642 *
643 * @param callback Callback to execute
644 */
645 moduleDone(callback: (details: QUnit.ModuleDoneDetails) => void | Promise<void>): void;
646
647 /**
648 * Register a callback to fire whenever a module begins.
649 *
650 * @param callback Callback to execute
651 */
652 moduleStart(callback: (details: QUnit.ModuleStartDetails) => void | Promise<void>): void;
653
654 /**
655 * Adds a test to exclusively run, preventing all other tests from running.
656 *
657 * Use this method to focus your test suite on a specific test. QUnit.only
658 * will cause any other tests in your suite to be ignored.
659 *
660 * Note, that if more than one QUnit.only is present only the first instance
661 * will run.
662 *
663 * This is an alternative to filtering tests to run in the HTML reporter. It
664 * is especially useful when you use a console reporter or in a codebase
665 * with a large set of long running tests.
666 *
667 * @param {string} name Title of unit being tested
668 * @param callback Function to close over assertions
669 */
670 only(name: string, callback: (assert: Assert) => void | Promise<void>): void;
671
672 /**
673 * Handle a global error that should result in a failed test run.
674 *
675 * @since 2.17.0
676 * @param {Error|any} error
677 */
678 onUncaughtException: (error: unknown) => void;
679
680 /**
681 * DEPRECATED: Report the result of a custom assertion.
682 *
683 * This method is deprecated and it's recommended to use pushResult on its
684 * direct reference in the assertion context.
685 *
686 * QUnit.push reflects to the current running test, and it may leak
687 * assertions in asynchronous mode. Checkout assert.pushResult() to set a
688 * proper custom assertion.
689 *
690 * Invoking QUnit.push allows to create a readable expectation that is not
691 * defined by any of QUnit's built-in assertions.
692 *
693 * @deprecated
694 */
695 push(result: boolean, actual: any, expected: any, message: string): void;
696
697 /**
698 * Adds a test like object to be skipped.
699 *
700 * Use this method to replace QUnit.test() instead of commenting out entire
701 * tests.
702 *
703 * This test's prototype will be listed on the suite as a skipped test,
704 * ignoring the callback argument and the respective global and module's
705 * hooks.
706 *
707 * @param {string} Title of unit being tested
708 */
709 skip(name: string, callback?: (assert: Assert) => void | Promise<void>): void;
710
711 /**
712 * Returns a single line string representing the stacktrace (call stack).
713 *
714 * This method returns a single line string representing the stacktrace from
715 * where it was called. According to its offset argument, `QUnit.stack()` will
716 * return the correspondent line from the call stack.
717 *
718 * The default `offset` is `0` and will return the current location where it
719 * was called.
720 *
721 * Not all browsers support retrieving stracktraces. In those, `QUnit.stack()`
722 * will return undefined.
723 *
724 * @param {number} offset Set the stacktrace line offset.
725 */
726 stack(offset?: number): string;
727
728 /**
729 * `QUnit.start()` must be used to start a test run that has
730 * `QUnit.config.autostart` set to `false`.
731 *
732 * This method was previously used to control async tests on text contexts
733 * along with QUnit.stop. For asynchronous tests, use assert.async instead.
734 *
735 * When your async test has multiple exit points, call `QUnit.start()` for the
736 * corresponding number of `QUnit.stop()` increments.
737 */
738 start(): void;
739
740 /**
741 * Add a test to run.
742 *
743 * Add a test to run using `QUnit.test()`.
744 *
745 * The `assert` argument to the callback contains all of QUnit's assertion
746 * methods. Use this argument to call your test assertions.
747 *
748 * `QUnit.test()` can automatically handle the asynchronous resolution of a
749 * Promise on your behalf if you return a thenable Promise as the result of
750 * your callback function.
751 *
752 * @param {string} Title of unit being tested
753 * @param callback Function to close over assertions
754 */
755 test(name: string, callback: (assert: Assert) => void | Promise<void>): void;
756
757 /**
758 * Register a callback to fire whenever a test ends.
759 *
760 * @param callback Callback to execute
761 */
762 testDone(
763 callback: (details: {
764 name: string;
765 module: string;
766 failed: number;
767 passed: number;
768 total: number;
769 runtime: number;
770 }) => void | Promise<void>,
771 ): void;
772
773 /**
774 * Register a callback to fire whenever a test begins.
775 *
776 * @param callback Callback to execute
777 */
778 testStart(callback: (details: QUnit.TestStartDetails) => void | Promise<void>): void;
779
780 /**
781 * Adds a test which expects at least one failing assertion during its run.
782 *
783 * Use this method to test a unit of code which is still under development
784 * (in a “todo” state). The test will pass as long as one failing assertion
785 * is present.
786 *
787 * If all assertions pass, then the test will fail signaling that QUnit.todo
788 * should be replaced by QUnit.test.
789 *
790 * @param {string} Title of unit being tested
791 * @param callback Function to close over assertions
792 */
793 todo(name: string, callback?: (assert: Assert) => void | Promise<void>): void;
794
795 /**
796 * Compares two values. Returns true if they are equivalent.
797 *
798 * @param a The first value
799 * @param b The second value
800 */
801 equiv<T>(a: T, b: T): boolean;
802
803 /**
804 * Are the test running from the server or not.
805 */
806 isLocal: boolean;
807
808 /**
809 * QUnit version
810 */
811 version: string;
812 }
813
814 /* QUnit */
815 const QUnit: QUnit;
816}
817
818export = QUnit;