1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687 |
x1
x1
x1
x1
x1
x1
x1
x1
x169
x169
x1
x693
x693
x1
x3
x3
x3
x1
x35
x35
x35
x35
x4
x35
x3
x3
x3
x35
x35
x35
x35
x35
x1
x14
x14
x14
x1
x27
x3
x3
x24
x27
x1
x7
x7
x7
x7
x7
x1
x228
x228
x1
x33
x33
x1
x1
x1
x1
x1
x1
x1
x32
x33
x1
x23
x23
x6
x6
x6
x6
x6
x6
x6
x23
x1
x13
x13
x6
x6
x6
x6
x6
x6
x6
x13
x1
x60
x60
x4
x4
x4
x4
x4
x4
x4
x60
x1
x8
x8
x4
x4
x4
x4
x4
x4
x4
x8
x1
x28
x28
x4
x4
x4
x4
x4
x4
x4
x4
x28
x1
x9
x9
x5
x5
x5
x5
x5
x5
x5
x5
x9
x1
x5
x5
x5
x5
x1
x1
x1
x1
x1
x1
x1
x5
x1
x4
x4
x4
x4
x1
x1
x1
x1
x1
x1
x1
x4
x1
x13
x13
x13
x13
x2
x2
x2
x2
x2
x2
x2
x13
x1
x10
x10
x10
x10
x2
x2
x2
x2
x2
x2
x2
x10
x1
x139
x139
x4
x4
x4
x4
x4
x4
x4
x4
x139
x1
x173
x173
x3
x3
x3
x3
x3
x3
x3
x3
x173
x1
x32
x32
x5
x5
x5
x5
x5
x5
x5
x5
x32
x1
x7
x7
x2
x2
x2
x2
x2
x2
x2
x2
x7
x1
x103
x103
x103
x5
x5
x5
x5
x5
x5
x5
x94
x94
x103
x93
x93
x3
x3
x3
x3
x3
x3
x3
x90
x90
x1
x1
x1
x1
x1
x1
x103
x1
x42
x42
x42
x42
x3
x3
x3
x3
x3
x3
x3
x35
x35
x35
x35
x42
x34
x34
x34
x42
x1
x1
x1
x1
x1
x1
x1
x34
x42
x4
x4
x4
x4
x4
x4
x4
x42
x1
x28
x28
x28
x28
x28
x28
x76
x76
x76 |
I
I
|
import '../../vendor/qunit.js';
import { objectValues, objectValuesSubset, validateExpectedExceptionArgs, validateException } from './index.ts';
import type { QUnitObject, AssertionErrorConstructor, InspectFn, TestState, ModuleState, PushResultInfo } from '../types.ts';
/**
* The assertion object passed to every test callback and lifecycle hook.
*
* Every {@linkcode test} callback receives an instance of `Assert` as its first argument.
* All assertion methods throw an {@linkcode AssertionError} on failure, which the test
* runner catches and reports.
*
* @example
* ```js
* import { module, test } from "qunitx";
*
* module("Math", () => {
* test("addition", (assert) => {
* assert.equal(1 + 1, 2);
* assert.strictEqual(typeof 42, "number");
* });
* });
* ```
*/
export default class Assert {
/** @internal Set by each runtime shim before tests run. */
static QUnit: QUnitObject;
/** @internal Set by each runtime shim before tests run. */
static AssertionError: AssertionErrorConstructor;
/** @internal Set by each runtime shim before tests run. */
static inspect: InspectFn;
/** @internal Mutable test state written during the test run. */
test: TestState;
/** @internal */
constructor(module: ModuleState | null, test?: TestState) {
this.test = test || (module as ModuleState).context;
}
/** @internal */
_incrementAssertionCount() {
this.test.totalExecutedAssertions++;
}
/**
* Sets the number of milliseconds after which the current test will fail if not yet complete.
*
* @param {number} number - Timeout in milliseconds (positive integer).
* @example
* ```js
* test("slow async operation", async (assert) => {
* assert.timeout(500);
* await somethingAsync();
* assert.ok(true);
* });
* ```
*/
timeout(number: number): void {
if (!Number.isInteger(number) || number < 0) {
throw new Error('assert.timeout() expects a positive integer.');
}
this.test.timeout = number;
}
/**
* Records a named step. Use with {@linkcode Assert.prototype.verifySteps} to assert that
* a sequence of steps occurred in the right order.
*
* @param {string} message - The step label to record.
* @example
* ```js
* test("event order", (assert) => {
* assert.expect(3);
* assert.step("step one");
* assert.step("step two");
* assert.verifySteps(["step one", "step two"]);
* });
* ```
*/
step(message: string): void {
let assertionMessage = message;
let result = !!message;
this.test.steps.push(message);
if (typeof message === 'undefined' || message === '') {
assertionMessage = 'You must provide a message to assert.step';
} else if (typeof message !== 'string') {
assertionMessage = 'You must provide a string value to assert.step';
result = false;
}
this.pushResult({
result,
message: assertionMessage
});
}
/**
* Asserts that the steps recorded via {@linkcode Assert.prototype.step} match the given array,
* then clears the recorded steps.
*
* @param {string[]} steps - Expected array of step labels in order.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* test("lifecycle order", (assert) => {
* assert.step("init");
* assert.step("run");
* assert.verifySteps(["init", "run"]);
* });
* ```
*/
verifySteps(steps: string[], message = 'Verify steps failed!') {
this.deepEqual(this.test.steps, steps, message);
this.test.steps.length = 0;
}
/**
* Sets the number of assertions expected to run in the current test.
* The test fails if a different number of assertions actually ran.
*
* @param {number} number - Expected assertion count (non-negative integer).
* @example
* ```js
* test("exactly two assertions", (assert) => {
* assert.expect(2);
* assert.ok(true);
* assert.ok(true);
* });
* ```
*/
expect(number: number): void {
if (!Number.isInteger(number) || number < 0) {
throw new Error('assert.expect() expects a positive integer.');
}
this.test.expectedAssertionCount = number;
}
/**
* Returns a `done` callback for callback-style async tests. The test will not
* finish until every `done` callback returned by `async()` has been called.
*
* For `async/await` tests prefer `async (assert) => { ... }` directly.
*
* @returns {function} A callback to invoke when the async work finishes.
* @example
* ```js
* test("async callback style", (assert) => {
* const done = assert.async();
* setTimeout(() => {
* assert.ok(true, "async callback ran");
* done();
* }, 10);
* });
* ```
*/
async(): () => void {
let resolveFn!: () => void;
const done = new Promise<void>(resolve => { resolveFn = resolve; });
this.test.asyncOps.push(done);
return () => { resolveFn(); };
}
/** @internal Used by the test runner to wait for all async operations to complete. */
waitForAsyncOps(): Promise<void[]> {
return Promise.all(this.test.asyncOps);
}
/**
* Pushes a custom assertion result. Fails the test if `resultInfo.result` is falsy.
* Throws an {@linkcode AssertionError} on failure.
*
* Useful for building custom assertion helpers.
*
* @param {{ result: boolean, actual?: unknown, expected?: unknown, message?: string }} resultInfo
* @example
* ```js
* test("custom assertion", (assert) => {
* assert.pushResult({
* result: 1 + 1 === 2,
* actual: 2,
* expected: 2,
* message: "custom math check",
* });
* });
* ```
*/
pushResult(resultInfo: PushResultInfo = {}): this {
this._incrementAssertionCount();
if (!resultInfo.result) {
throw new Assert.AssertionError({
actual: resultInfo.actual,
expected: resultInfo.expected,
message: resultInfo.message || 'Custom assertion failed!',
stackStartFn: this.pushResult,
});
}
return this;
}
/**
* Asserts that `state` is truthy.
*
* @param {unknown} state - The value to test.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.ok(true);
* assert.ok(1, "non-zero is truthy");
* assert.ok("hello");
* ```
*/
ok(state: unknown, message?: string): void {
this._incrementAssertionCount();
if (!state) {
throw new Assert.AssertionError({
actual: state,
expected: true,
message: message || `Expected argument to be truthy, it was: ${inspect(state)}`,
stackStartFn: this.ok,
});
}
}
/**
* Asserts that `state` is falsy.
*
* @param {unknown} state - The value to test.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.notOk(false);
* assert.notOk(0, "zero is falsy");
* assert.notOk(null);
* ```
*/
notOk(state: unknown, message?: string): void {
this._incrementAssertionCount();
if (state) {
throw new Assert.AssertionError({
actual: state,
expected: false,
message: message || `Expected argument to be falsy, it was: ${inspect(state)}`,
stackStartFn: this.notOk,
});
}
}
/**
* Asserts that `state === true` (strict boolean true).
*
* @param {unknown} state - The value to test.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.true(1 === 1);
* assert.true(Array.isArray([]), "arrays are arrays");
* ```
*/
true(state: unknown, message?: string): void {
this._incrementAssertionCount();
if (state !== true) {
throw new Assert.AssertionError({
actual: state,
expected: true,
message: message || `Expected argument to be true, it was: ${inspect(state)}`,
stackStartFn: this.true,
});
}
}
/**
* Asserts that `state === false` (strict boolean false).
*
* @param {unknown} state - The value to test.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.false(1 === 2);
* assert.false(Number.isNaN(42), "42 is not NaN");
* ```
*/
false(state: unknown, message?: string): void {
this._incrementAssertionCount();
if (state !== false) {
throw new Assert.AssertionError({
actual: state,
expected: false,
message: message || `Expected argument to be false, it was: ${inspect(state)}`,
stackStartFn: this.false,
});
}
}
/**
* Asserts that `actual == expected` (loose equality, allows type coercion).
*
* Prefer {@linkcode Assert.prototype.strictEqual} for most comparisons. Use {@linkcode Assert.prototype.notEqual}
* for the inverse.
*
* @param {unknown} actual - The value produced by the code under test.
* @param {unknown} expected - The expected value.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.equal(1, 1);
* assert.equal("1", 1, "loose equality allows coercion");
* ```
*/
equal(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
if (actual != expected) {
throw new Assert.AssertionError({
actual,
expected,
message: message || `Expected: ${defaultMessage(actual, 'should equal to:', expected)}`,
operator: '==',
stackStartFn: this.equal,
});
}
}
/**
* Asserts that `actual != expected` (loose inequality). Inverse of {@linkcode Assert.prototype.equal}.
*
* @param {unknown} actual - The actual value.
* @param {unknown} expected - The value it should not loosely equal.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.notEqual(1, 2);
* assert.notEqual("hello", "world");
* ```
*/
notEqual(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
if (actual == expected) {
throw new Assert.AssertionError({
actual,
expected,
operator: '!=',
message: message || `Expected: ${defaultMessage(actual, 'should notEqual to:', expected)}`,
stackStartFn: this.notEqual,
});
}
}
/**
* Asserts that `actual` and `expected` have the same own enumerable properties
* and values. Prototype methods are ignored; only own properties are compared.
*
* @param {object} actual - The actual object.
* @param {object} expected - The expected object.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.propEqual({ a: 1, b: 2 }, { a: 1, b: 2 });
*
* // Ignores prototype methods — only own properties matter:
* function Point(x, y) { this.x = x; this.y = y; }
* assert.propEqual(new Point(1, 2), { x: 1, y: 2 });
* ```
*/
propEqual(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
const targetActual = objectValues(actual);
const targetExpected = objectValues(expected);
if (!Assert.QUnit.equiv(targetActual, targetExpected)) {
throw new Assert.AssertionError({
actual: targetActual,
expected: targetExpected,
message: message || `Expected properties to be propEqual: ${defaultMessage(targetActual, 'should propEqual to:', targetExpected)}`,
stackStartFn: this.propEqual,
});
}
}
/**
* Asserts that `actual` and `expected` do NOT have the same own enumerable
* properties and values. Inverse of {@linkcode Assert.prototype.propEqual}.
*
* @param {object} actual - The actual object.
* @param {object} expected - The value it should not propEqual.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.notPropEqual({ a: 1 }, { a: 2 });
* assert.notPropEqual({ a: 1, b: 2 }, { a: 1 }); // extra key makes them unequal
* ```
*/
notPropEqual(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
const targetActual = objectValues(actual);
const targetExpected = objectValues(expected);
if (Assert.QUnit.equiv(targetActual, targetExpected)) {
throw new Assert.AssertionError({
actual: targetActual,
expected: targetExpected,
message: message || `Expected properties to NOT be propEqual: ${defaultMessage(targetActual, 'should notPropEqual to:', targetExpected)}`,
stackStartFn: this.notPropEqual,
});
}
}
/**
* Asserts that `actual` contains all own enumerable properties from `expected`
* with matching values. Extra properties on `actual` are allowed and ignored.
*
* @param {object} actual - The actual object (may have extra keys).
* @param {object} expected - The subset of key/value pairs that must be present.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.propContains({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 });
* assert.propContains(user, { role: "admin" });
* ```
*/
propContains(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
const targetActual = objectValuesSubset(actual, expected);
const targetExpected = objectValues(expected, false);
if (!Assert.QUnit.equiv(targetActual, targetExpected)) {
throw new Assert.AssertionError({
actual: targetActual,
expected: targetExpected,
message: message || `propContains assertion fail on: ${defaultMessage(targetActual, 'should propContains to:', targetExpected)}`,
stackStartFn: this.propContains,
});
}
}
/**
* Asserts that `actual` does NOT contain all own enumerable properties
* from `expected` with matching values. Inverse of {@linkcode Assert.prototype.propContains}.
*
* @param {object} actual - The actual object.
* @param {object} expected - The subset of properties that must NOT all match.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.notPropContains({ a: 1, b: 2 }, { a: 9 });
* assert.notPropContains(user, { role: "banned" });
* ```
*/
notPropContains(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
const targetActual = objectValuesSubset(actual, expected);
const targetExpected = objectValues(expected);
if (Assert.QUnit.equiv(targetActual, targetExpected)) {
throw new Assert.AssertionError({
actual: targetActual,
expected: targetExpected,
message: message || `notPropContains assertion fail on: ${defaultMessage(targetActual, 'should notPropContains of:', targetExpected)}`,
stackStartFn: this.notPropContains,
});
}
}
/**
* Asserts deep equality between `actual` and `expected` using recursive structural
* comparison. Handles nested objects, arrays, `Date`, `RegExp`, and more.
*
* @param {unknown} actual - The actual value.
* @param {unknown} expected - The expected value.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.deepEqual([1, { a: 2 }], [1, { a: 2 }]);
* assert.deepEqual(new Date("2024-01-01"), new Date("2024-01-01"));
* ```
*/
deepEqual(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
if (!Assert.QUnit.equiv(actual, expected)) {
throw new Assert.AssertionError({
actual,
expected,
message: message || `Expected values to be deepEqual: ${defaultMessage(actual, 'should deepEqual to:', expected)}`,
operator: 'deepEqual',
stackStartFn: this.deepEqual,
});
}
}
/**
* Asserts that `actual` and `expected` are NOT deeply equal. Inverse of {@linkcode Assert.prototype.deepEqual}.
*
* @param {unknown} actual - The actual value.
* @param {unknown} expected - The value it should not deepEqual.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.notDeepEqual([1, 2], [1, 3]);
* assert.notDeepEqual({ a: 1 }, { a: 2 });
* ```
*/
notDeepEqual(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
if (Assert.QUnit.equiv(actual, expected)) {
throw new Assert.AssertionError({
actual,
expected,
message: message || `Expected values to be NOT deepEqual: ${defaultMessage(actual, 'should notDeepEqual to:', expected)}`,
operator: 'notDeepEqual',
stackStartFn: this.notDeepEqual,
});
}
}
/**
* Asserts that `actual === expected` (strict equality, no type coercion).
*
* @param {unknown} actual - The actual value.
* @param {unknown} expected - The expected value.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.strictEqual(1 + 1, 2);
* assert.strictEqual(typeof "hello", "string");
* ```
*/
strictEqual(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
if (actual !== expected) {
throw new Assert.AssertionError({
actual,
expected,
message: message || `Expected: ${defaultMessage(actual, 'is strictEqual to:', expected)}`,
operator: 'strictEqual',
stackStartFn: this.strictEqual,
});
}
}
/**
* Asserts that `actual !== expected` (strict inequality). Inverse of {@linkcode Assert.prototype.strictEqual}.
*
* @param {unknown} actual - The actual value.
* @param {unknown} expected - The value it should not strictly equal.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.notStrictEqual(1, "1", "different types");
* assert.notStrictEqual({}, {}, "different object references");
* ```
*/
notStrictEqual(actual: unknown, expected: unknown, message?: string): void {
this._incrementAssertionCount();
if (actual === expected) {
throw new Assert.AssertionError({
actual,
expected,
message: message || `Expected: ${defaultMessage(actual, 'is notStrictEqual to:', expected)}`,
operator: 'notStrictEqual',
stackStartFn: this.notStrictEqual,
});
}
}
/**
* Asserts that `blockFn` throws an exception. Optionally validates the thrown
* error against a string (message substring), RegExp (message pattern),
* or constructor (`instanceof` check). For async functions use {@linkcode Assert.prototype.rejects}.
*
* @param {function} blockFn - A synchronous function expected to throw.
* @param {string|RegExp|function} [expected] - Optional matcher for the thrown error.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* assert.throws(() => { throw new Error("boom"); });
* assert.throws(() => JSON.parse("{bad}"), SyntaxError);
* assert.throws(() => { throw new Error("bad input"); }, /bad input/);
* ```
*/
throws(blockFn: unknown, expectedInput?: unknown, assertionMessage?: string): void {
this?._incrementAssertionCount();
const [expected, message] = validateExpectedExceptionArgs(expectedInput, assertionMessage, 'throws');
if (typeof blockFn !== 'function') {
throw new Assert.AssertionError({
actual: blockFn,
expected: Function,
message: 'The value provided to `assert.throws` was not a function.',
stackStartFn: this.throws,
});
}
try {
blockFn();
} catch (error) {
const [result, validatedExpected, validatedMessage] = validateException(error, expected, message);
if (result === false) {
throw new Assert.AssertionError({
actual: result,
expected: validatedExpected,
message: validatedMessage,
stackStartFn: this.throws,
});
}
return;
}
throw new Assert.AssertionError({
actual: blockFn,
expected: expected,
message: 'Function passed to `assert.throws` did not throw an exception!',
stackStartFn: this.throws,
});
}
/**
* Asserts that a promise rejects. Optionally validates the rejection reason
* against a string (message substring), RegExp (message pattern),
* or constructor (`instanceof` check). For synchronous throws use {@linkcode Assert.prototype.throws}.
*
* @param {Promise<unknown>} promise - A promise expected to reject.
* @param {string|RegExp|function} [expected] - Optional matcher for the rejection reason.
* @param {string} [message] - Optional failure message.
* @example
* ```js
* await assert.rejects(Promise.reject(new Error("oops")));
* await assert.rejects(fetch("/bad-url"), TypeError);
* await assert.rejects(Promise.reject(new Error("timeout")), /timeout/);
* ```
*/
async rejects(promise: unknown, expectedInput?: unknown, assertionMessage?: string): Promise<void> {
this._incrementAssertionCount();
const [expected, message] = validateExpectedExceptionArgs(expectedInput, assertionMessage, 'rejects');
const then = promise && (promise as PromiseLike<unknown>).then;
if (typeof then !== 'function') {
throw new Assert.AssertionError({
actual: promise,
expected: expected,
message: 'The value provided to `assert.rejects` was not a promise!',
stackStartFn: this.rejects,
});
}
let didReject = false;
let rejectionError;
try {
await promise;
} catch (error) {
didReject = true;
rejectionError = error;
}
if (!didReject) {
throw new Assert.AssertionError({
actual: promise,
expected: expected,
message: 'The promise returned by the `assert.rejects` callback did not reject!',
stackStartFn: this.rejects,
});
}
const [result, validatedExpected, validatedMessage] = validateException(rejectionError, expected, message);
if (result === false) {
throw new Assert.AssertionError({
actual: result,
expected: validatedExpected,
message: validatedMessage,
stackStartFn: this.rejects,
});
}
}
};
function defaultMessage(actual: unknown, description: string, expected: unknown): string {
return `
${inspect(actual)}
${description}
${inspect(expected)}`
}
function inspect(value: unknown): string {
return Assert.inspect(value, { depth: 10, colors: true, compact: false });
}
|