UNPKG

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