@everyonesoftware/common 6.0.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { S as SyncResult, P as PromiseAsyncResult, k as Type, I as Iterable, f as JavascriptIterable, C as CharacterWriteStream } from './characterWriteStream-DUlG_bx_.cjs';
1
+ import { f as JavascriptIterable, S as SyncResult, P as PromiseAsyncResult, k as Type, I as Iterable, A as AsyncResult, C as CharacterWriteStream } from './characterWriteStream-ogvZec-U.cjs';
2
2
 
3
3
  /**
4
4
  * A type that can be used to make assertions during a test.
@@ -61,6 +61,12 @@ declare abstract class Test {
61
61
  * @param value The value to check.
62
62
  */
63
63
  static assertNotUndefinedAndNotNull<T>(test: Test, value: T): asserts value is NonNullable<T>;
64
+ /**
65
+ * Assert that the provided collection is not undefined, not null, and not empty.
66
+ * @param value The value to check.
67
+ */
68
+ assertNotEmpty(value: JavascriptIterable<unknown>): void;
69
+ static assertNotEmpty(test: Test, value: JavascriptIterable<unknown>): void;
64
70
  /**
65
71
  * Assert that the provided values point to the same object.
66
72
  * @param left The first value.
@@ -91,10 +97,6 @@ declare abstract class Test {
91
97
  * @param value The value to check.
92
98
  */
93
99
  assertFalse(value: boolean): asserts value is false;
94
- /**
95
- * Assert that the provided value is false.
96
- * @param value The value to check.
97
- */
98
100
  static assertFalse(test: Test, value: boolean): asserts value is false;
99
101
  /**
100
102
  * Assert that the provided value is true.
@@ -154,6 +156,7 @@ declare class AssertTest implements Test {
154
156
  assertNull(value: unknown): asserts value is null;
155
157
  assertNotNull<T>(value: T): asserts value is NonNullable<T>;
156
158
  assertNotUndefinedAndNotNull<T>(value: T): asserts value is NonNullable<T>;
159
+ assertNotEmpty(value: JavascriptIterable<unknown>): void;
157
160
  assertSame<T>(left: T, right: T): void;
158
161
  assertNotSame<T>(left: T, right: T): void;
159
162
  assertEqual<T>(left: T, right: T, message?: string): void;
@@ -228,61 +231,44 @@ declare abstract class TestRunner {
228
231
  * @param message The message that explains why the tests are being skipped.
229
232
  */
230
233
  static skip(_runner: TestRunner, shouldSkip?: boolean, message?: string): TestSkip;
231
- static runTestAction(runner: TestRunner, name: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
232
234
  /**
233
235
  * Create a test group that will test the provided file.
234
236
  * @param fileName The name of the file that is being tested.
235
237
  * @param testAction The action that will run the tests.
236
238
  */
237
- testFile(fileName: string, testAction: (() => void) | ((test: Test) => void)): void;
239
+ abstract testFile(fileName: string, testAction: (() => void) | ((test: Test) => void)): void;
238
240
  /**
239
241
  * Create a test group that will test the provided file.
240
242
  * @param fileName The name of the file that is being tested.
241
243
  * @param skip A value that indicates whether these tests should be skipped.
242
244
  * @param testAction The action that will run the tests.
243
245
  */
244
- testFile(fileName: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
245
- /**
246
- * Create a test group that will test the provided file.
247
- * @param runner The {@link TestRunner} that will run the tests.
248
- * @param fileName The name of the file that is being tested.
249
- * @param testAction The action that will run the tests.
250
- */
251
- static testFile(runner: TestRunner, fileName: string, skipOrTestAction: TestSkip | ((() => void) | ((test: Test) => void)) | undefined, testAction?: (() => void) | ((test: Test) => void)): void;
246
+ abstract testFile(fileName: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
252
247
  /**
253
248
  * Create a test group that will test the provided type.
254
249
  * @param type The {@link Type} or name of the type that is being tested.
255
250
  * @param testAction The action that will run the tests.
256
251
  */
257
- testType(typeNameOrType: string | Type<unknown>, testAction: (() => void) | ((test: Test) => void)): void;
252
+ abstract testType(typeNameOrType: string | Type<unknown>, testAction: (() => void) | ((test: Test) => void)): void;
258
253
  /**
259
254
  * Create a test group that will test the provided type.
260
255
  * @param type The {@link Type} or name of the type that is being tested.
261
256
  * @param skip A value that indicates whether these tests should be skipped.
262
257
  * @param testAction The action that will run the tests.
263
258
  */
264
- testType(typeNameOrType: string | Type<unknown>, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
265
- /**
266
- * Create a test group that will test the provided type.
267
- * @param runner The {@link TestRunner} that will run the tests.
268
- * @param type The {@link Type} or name of the type that is being tested.
269
- * @param testAction The action that will run the tests.
270
- */
271
- static testType(runner: TestRunner, typeNameOrType: string | Type<unknown>, skipOrTestAction: TestSkip | undefined | ((() => void) | ((test: Test) => void)), testAction: ((() => void) | ((test: Test) => void)) | undefined): void;
259
+ abstract testType(typeNameOrType: string | Type<unknown>, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
272
260
  /**
273
261
  * Create a test group that will test the provided function.
274
262
  * @param functionSignature The signature of the function that is being tested.
275
263
  * @param testAction The action that will run the tests.
276
264
  */
277
- testFunction(functionSignature: string, testAction: (() => void) | ((test: Test) => void)): void;
278
- testFunction(functionSignature: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
265
+ abstract testFunction(functionSignature: string, testAction: (() => void) | ((test: Test) => void)): void;
279
266
  /**
280
267
  * Create a test group that will test the provided function.
281
- * @param runner The {@link TestRunner} that will run the tests.
282
268
  * @param functionSignature The signature of the function that is being tested.
283
269
  * @param testAction The action that will run the tests.
284
270
  */
285
- static testFunction(runner: TestRunner, functionSignature: string, skipOrTestAction: TestSkip | undefined | ((() => void) | ((test: Test) => void)), testAction: ((() => void) | ((test: Test) => void)) | undefined): void;
271
+ abstract testFunction(functionSignature: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
286
272
  /**
287
273
  * Create and run a test group with the provided name.
288
274
  * @param testGroupName The name of the test group to run.
@@ -330,71 +316,118 @@ declare class BasicTestSkip implements TestSkip {
330
316
  getMessage(): string;
331
317
  }
332
318
 
333
- declare class FailedTest {
334
- private readonly fullTestNameParts;
335
- private readonly error;
336
- private constructor();
337
- static create(fullTestNameParts: JavascriptIterable<string>, error: unknown): FailedTest;
338
- getFullTestNameParts(): JavascriptIterable<string>;
339
- getFullTestName(): string;
340
- getError(): unknown;
341
- getErrorMessage(): string;
342
- }
343
-
344
- declare class SkippedTest {
345
- private readonly skip;
346
- private readonly fullTestNameParts;
347
- private constructor();
348
- static create(skip: TestSkip, fullTestNameParts: JavascriptIterable<string>): SkippedTest;
349
- getSkipMessage(): string;
350
- getFullTestNameParts(): JavascriptIterable<string>;
351
- getFullTestName(): string;
352
- }
353
-
319
+ type TestActionType = "file" | "type" | "function" | "group" | "test";
354
320
  declare class TestAction {
355
321
  private readonly parent;
356
322
  private readonly name;
323
+ private readonly type;
357
324
  private readonly skip;
358
325
  private readonly action;
359
326
  private constructor();
360
- static create(parent: TestAction | undefined, name: string, skip: TestSkip | undefined, action: () => (void | Promise<void>)): TestAction;
327
+ static create(parent: TestAction | undefined, name: string, type: TestActionType, skip: TestSkip | undefined, action: () => (void | Promise<void>)): TestAction;
361
328
  getParent(): TestAction | undefined;
362
329
  getName(): string;
363
330
  getFullNameParts(): JavascriptIterable<string>;
364
331
  getFullName(): string;
332
+ getType(): TestActionType;
365
333
  getSkip(): TestSkip | undefined;
366
334
  shouldSkip(): boolean;
367
335
  getAction(): () => (void | Promise<void>);
368
336
  runAsync(): void | Promise<void>;
369
337
  }
370
338
 
339
+ declare class FailedTest {
340
+ private readonly testAction;
341
+ private readonly error;
342
+ private constructor();
343
+ static create(testAction: TestAction, error: unknown): FailedTest;
344
+ getTestAction(): TestAction;
345
+ getError(): unknown;
346
+ getErrorMessage(): string;
347
+ }
348
+
349
+ declare class SkippedTest {
350
+ private readonly skip;
351
+ private readonly testAction;
352
+ private constructor();
353
+ static create(skip: TestSkip, testAction: TestAction): SkippedTest;
354
+ getSkipMessage(): string;
355
+ getTestAction(): TestAction;
356
+ }
357
+
358
+ type ConsoleTestRunnerStyle = TestActionType | "passed" | "skipped" | "failed";
359
+ declare abstract class ConsoleTestRunnerUI {
360
+ private writeStream?;
361
+ private readonly styles;
362
+ protected constructor();
363
+ static flat(): FlatConsoleTestRunnerUI;
364
+ static tree(): TreeConsoleTestRunnerUI;
365
+ setWriteStream(writeStream: CharacterWriteStream): this;
366
+ setStyle(style: ConsoleTestRunnerStyle, styleFunction: (text: string) => string): this;
367
+ setStyles(styles: Partial<Record<ConsoleTestRunnerStyle, (text: string) => string>>): this;
368
+ private applyStyle;
369
+ protected addIndentation(): void;
370
+ protected removeIndentation(): void;
371
+ protected indent(action: () => number | void | PromiseLike<number | void>): AsyncResult<number>;
372
+ protected writeString(text: string): AsyncResult<number>;
373
+ protected writeLine(text?: string): AsyncResult<number>;
374
+ protected writeTestActionName(testAction: TestAction): AsyncResult<number>;
375
+ protected writeFullTestActionName(testAction: TestAction): AsyncResult<number>;
376
+ beforeTestGroup(testGroup: TestAction): AsyncResult<void>;
377
+ afterTestGroup(testGroup: TestAction): AsyncResult<void>;
378
+ beforeTest(testAction: TestAction): AsyncResult<void>;
379
+ afterPassedTest(testAction: TestAction): AsyncResult<void>;
380
+ afterSkippedTest(testAction: TestAction, skip: TestSkip): AsyncResult<void>;
381
+ afterFailedTest(currentTestAction: TestAction, error: unknown): AsyncResult<void>;
382
+ writeSummary(passedTestCount: number, skippedTests: Iterable<SkippedTest>, failedTests: Iterable<FailedTest>): AsyncResult<void>;
383
+ }
384
+ declare class FlatConsoleTestRunnerUI extends ConsoleTestRunnerUI {
385
+ protected constructor();
386
+ static create(): FlatConsoleTestRunnerUI;
387
+ beforeTest(testAction: TestAction): AsyncResult<void>;
388
+ }
389
+ declare class TreeConsoleTestRunnerUI extends ConsoleTestRunnerUI {
390
+ private testActions;
391
+ private testActionWrittenDepth;
392
+ protected constructor();
393
+ static create(): TreeConsoleTestRunnerUI;
394
+ beforeTestGroup(testGroup: TestAction): AsyncResult<void>;
395
+ afterTestGroup(testGroup: TestAction): AsyncResult<void>;
396
+ beforeTest(testAction: TestAction): AsyncResult<void>;
397
+ }
398
+
371
399
  type ConsoleTestFunction = (runner: ConsoleTestRunner) => (void | Promise<void>);
372
400
  type ConsoleTestFunctionContainer = {
373
401
  test: ConsoleTestFunction;
374
402
  };
375
- declare class ConsoleTestRunner extends TestRunner {
403
+ declare class ConsoleTestRunner implements TestRunner {
376
404
  private writeStream;
377
- private readonly pendingActions;
378
- private pendingActionsInsertIndex;
405
+ private readonly testActions;
406
+ private testActionInsertIndex;
379
407
  private currentTestAction;
380
408
  private currentTest;
381
409
  private passedTestCount;
382
410
  private readonly skippedTests;
383
411
  private readonly testFailures;
384
- constructor();
385
- static create(): ConsoleTestRunner;
412
+ private readonly ui;
413
+ constructor(ui?: ConsoleTestRunnerUI);
414
+ static create(ui?: ConsoleTestRunnerUI): ConsoleTestRunner;
386
415
  static run(testFunction: ConsoleTestFunction | ConsoleTestFunctionContainer): Promise<void>;
387
416
  static run(testFunctions: JavascriptIterable<ConsoleTestFunction | ConsoleTestFunctionContainer>): Promise<void>;
388
417
  setWriteStream(writeStream: CharacterWriteStream): this;
418
+ setStyle(style: ConsoleTestRunnerStyle, styleFunction: (text: string) => string): this;
419
+ setStyles(styles: Partial<Record<ConsoleTestRunnerStyle, (text: string) => string>>): this;
389
420
  /**
390
421
  * Get the number of {@link TestAction}s that have yet to be executed.
391
422
  */
392
- getPendingTestActionsCount(): number;
423
+ getTestActionCount(): number;
393
424
  /**
394
- * Get the index in the pending-{@link TestAction} stack that new {@link TestAction}s will be
425
+ * Get the index in the {@link TestAction} list that new {@link TestAction}s will be
395
426
  * inserted at.
396
427
  */
397
- getPendingTestActionsInsertIndex(): number;
428
+ getTestActionInsertIndex(): number;
429
+ private resetTestActionInsertIndex;
430
+ private insertTestAction;
398
431
  /**
399
432
  * Get the number of tests that have been skipped.
400
433
  */
@@ -413,16 +446,31 @@ declare class ConsoleTestRunner extends TestRunner {
413
446
  getCurrentTestAction(): TestAction | undefined;
414
447
  getCurrentTest(): Test | undefined;
415
448
  private assertNoCurrentTest;
416
- beforeTest(fullTestNameParts: JavascriptIterable<string>): PromiseAsyncResult<void>;
417
- afterPassedTest(): PromiseAsyncResult<void>;
418
- afterSkippedTest(fullTestNameParts: JavascriptIterable<string>, skip: TestSkip | undefined): PromiseAsyncResult<void>;
419
- afterFailedTest(fullTestNameParts: JavascriptIterable<string>, error: unknown): PromiseAsyncResult<void>;
449
+ beforeTestGroup(testAction: TestAction): AsyncResult<void>;
450
+ afterTestGroup(testAction: TestAction): AsyncResult<void>;
451
+ beforeTest(testAction: TestAction): AsyncResult<void>;
452
+ afterPassedTest(testAction: TestAction): AsyncResult<void>;
453
+ afterSkippedTest(testAction: TestAction, skip: TestSkip): AsyncResult<void>;
454
+ afterFailedTest(testAction: TestAction, error: unknown): AsyncResult<void>;
455
+ andList(values: unknown[] | Iterable<unknown>): string;
456
+ toString(value: unknown): string;
457
+ skip(message?: string): TestSkip;
458
+ skip(shouldSkip: boolean, message?: string): TestSkip;
459
+ testFile(fileName: string, testAction: (() => void) | ((test: Test) => void)): void;
460
+ testFile(fileName: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
461
+ testType(typeNameOrType: string | Type<unknown>, testAction: (() => void) | ((test: Test) => void)): void;
462
+ testType(typeNameOrType: string | Type<unknown>, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
463
+ testFunction(functionSignature: string, testAction: (() => void) | ((test: Test) => void)): void;
464
+ testFunction(functionSignature: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
420
465
  testGroup(testGroupName: string, testAction: () => (void | Promise<void>)): void;
421
466
  testGroup(testGroupName: string, skip: TestSkip | undefined, testAction: () => (void | Promise<void>)): void;
422
467
  test(testName: string, testAction: (test: Test) => (void | Promise<void>)): void;
423
468
  test(testName: string, skip: TestSkip | undefined, testAction: (test: Test) => (void | Promise<void>)): void;
469
+ private innerTestGroup;
470
+ private innerTest;
471
+ private testGroupOrTest;
424
472
  runAsync(): Promise<void>;
425
- printSummary(): PromiseAsyncResult<void>;
473
+ printSummary(): AsyncResult<void>;
426
474
  }
427
475
 
428
- export { AssertTest, BasicTestSkip, type ConsoleTestFunction, type ConsoleTestFunctionContainer, ConsoleTestRunner, FailedTest, SkippedTest, Test, TestAction, TestRunner, TestSkip, test };
476
+ export { AssertTest, BasicTestSkip, type ConsoleTestFunction, type ConsoleTestFunctionContainer, ConsoleTestRunner, FailedTest, SkippedTest, Test, TestAction, type TestActionType, TestRunner, TestSkip, test };
@@ -1,4 +1,4 @@
1
- import { S as SyncResult, P as PromiseAsyncResult, k as Type, I as Iterable, f as JavascriptIterable, C as CharacterWriteStream } from './characterWriteStream-DUlG_bx_.js';
1
+ import { f as JavascriptIterable, S as SyncResult, P as PromiseAsyncResult, k as Type, I as Iterable, A as AsyncResult, C as CharacterWriteStream } from './characterWriteStream-ogvZec-U.js';
2
2
 
3
3
  /**
4
4
  * A type that can be used to make assertions during a test.
@@ -61,6 +61,12 @@ declare abstract class Test {
61
61
  * @param value The value to check.
62
62
  */
63
63
  static assertNotUndefinedAndNotNull<T>(test: Test, value: T): asserts value is NonNullable<T>;
64
+ /**
65
+ * Assert that the provided collection is not undefined, not null, and not empty.
66
+ * @param value The value to check.
67
+ */
68
+ assertNotEmpty(value: JavascriptIterable<unknown>): void;
69
+ static assertNotEmpty(test: Test, value: JavascriptIterable<unknown>): void;
64
70
  /**
65
71
  * Assert that the provided values point to the same object.
66
72
  * @param left The first value.
@@ -91,10 +97,6 @@ declare abstract class Test {
91
97
  * @param value The value to check.
92
98
  */
93
99
  assertFalse(value: boolean): asserts value is false;
94
- /**
95
- * Assert that the provided value is false.
96
- * @param value The value to check.
97
- */
98
100
  static assertFalse(test: Test, value: boolean): asserts value is false;
99
101
  /**
100
102
  * Assert that the provided value is true.
@@ -154,6 +156,7 @@ declare class AssertTest implements Test {
154
156
  assertNull(value: unknown): asserts value is null;
155
157
  assertNotNull<T>(value: T): asserts value is NonNullable<T>;
156
158
  assertNotUndefinedAndNotNull<T>(value: T): asserts value is NonNullable<T>;
159
+ assertNotEmpty(value: JavascriptIterable<unknown>): void;
157
160
  assertSame<T>(left: T, right: T): void;
158
161
  assertNotSame<T>(left: T, right: T): void;
159
162
  assertEqual<T>(left: T, right: T, message?: string): void;
@@ -228,61 +231,44 @@ declare abstract class TestRunner {
228
231
  * @param message The message that explains why the tests are being skipped.
229
232
  */
230
233
  static skip(_runner: TestRunner, shouldSkip?: boolean, message?: string): TestSkip;
231
- static runTestAction(runner: TestRunner, name: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
232
234
  /**
233
235
  * Create a test group that will test the provided file.
234
236
  * @param fileName The name of the file that is being tested.
235
237
  * @param testAction The action that will run the tests.
236
238
  */
237
- testFile(fileName: string, testAction: (() => void) | ((test: Test) => void)): void;
239
+ abstract testFile(fileName: string, testAction: (() => void) | ((test: Test) => void)): void;
238
240
  /**
239
241
  * Create a test group that will test the provided file.
240
242
  * @param fileName The name of the file that is being tested.
241
243
  * @param skip A value that indicates whether these tests should be skipped.
242
244
  * @param testAction The action that will run the tests.
243
245
  */
244
- testFile(fileName: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
245
- /**
246
- * Create a test group that will test the provided file.
247
- * @param runner The {@link TestRunner} that will run the tests.
248
- * @param fileName The name of the file that is being tested.
249
- * @param testAction The action that will run the tests.
250
- */
251
- static testFile(runner: TestRunner, fileName: string, skipOrTestAction: TestSkip | ((() => void) | ((test: Test) => void)) | undefined, testAction?: (() => void) | ((test: Test) => void)): void;
246
+ abstract testFile(fileName: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
252
247
  /**
253
248
  * Create a test group that will test the provided type.
254
249
  * @param type The {@link Type} or name of the type that is being tested.
255
250
  * @param testAction The action that will run the tests.
256
251
  */
257
- testType(typeNameOrType: string | Type<unknown>, testAction: (() => void) | ((test: Test) => void)): void;
252
+ abstract testType(typeNameOrType: string | Type<unknown>, testAction: (() => void) | ((test: Test) => void)): void;
258
253
  /**
259
254
  * Create a test group that will test the provided type.
260
255
  * @param type The {@link Type} or name of the type that is being tested.
261
256
  * @param skip A value that indicates whether these tests should be skipped.
262
257
  * @param testAction The action that will run the tests.
263
258
  */
264
- testType(typeNameOrType: string | Type<unknown>, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
265
- /**
266
- * Create a test group that will test the provided type.
267
- * @param runner The {@link TestRunner} that will run the tests.
268
- * @param type The {@link Type} or name of the type that is being tested.
269
- * @param testAction The action that will run the tests.
270
- */
271
- static testType(runner: TestRunner, typeNameOrType: string | Type<unknown>, skipOrTestAction: TestSkip | undefined | ((() => void) | ((test: Test) => void)), testAction: ((() => void) | ((test: Test) => void)) | undefined): void;
259
+ abstract testType(typeNameOrType: string | Type<unknown>, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
272
260
  /**
273
261
  * Create a test group that will test the provided function.
274
262
  * @param functionSignature The signature of the function that is being tested.
275
263
  * @param testAction The action that will run the tests.
276
264
  */
277
- testFunction(functionSignature: string, testAction: (() => void) | ((test: Test) => void)): void;
278
- testFunction(functionSignature: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
265
+ abstract testFunction(functionSignature: string, testAction: (() => void) | ((test: Test) => void)): void;
279
266
  /**
280
267
  * Create a test group that will test the provided function.
281
- * @param runner The {@link TestRunner} that will run the tests.
282
268
  * @param functionSignature The signature of the function that is being tested.
283
269
  * @param testAction The action that will run the tests.
284
270
  */
285
- static testFunction(runner: TestRunner, functionSignature: string, skipOrTestAction: TestSkip | undefined | ((() => void) | ((test: Test) => void)), testAction: ((() => void) | ((test: Test) => void)) | undefined): void;
271
+ abstract testFunction(functionSignature: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
286
272
  /**
287
273
  * Create and run a test group with the provided name.
288
274
  * @param testGroupName The name of the test group to run.
@@ -330,71 +316,118 @@ declare class BasicTestSkip implements TestSkip {
330
316
  getMessage(): string;
331
317
  }
332
318
 
333
- declare class FailedTest {
334
- private readonly fullTestNameParts;
335
- private readonly error;
336
- private constructor();
337
- static create(fullTestNameParts: JavascriptIterable<string>, error: unknown): FailedTest;
338
- getFullTestNameParts(): JavascriptIterable<string>;
339
- getFullTestName(): string;
340
- getError(): unknown;
341
- getErrorMessage(): string;
342
- }
343
-
344
- declare class SkippedTest {
345
- private readonly skip;
346
- private readonly fullTestNameParts;
347
- private constructor();
348
- static create(skip: TestSkip, fullTestNameParts: JavascriptIterable<string>): SkippedTest;
349
- getSkipMessage(): string;
350
- getFullTestNameParts(): JavascriptIterable<string>;
351
- getFullTestName(): string;
352
- }
353
-
319
+ type TestActionType = "file" | "type" | "function" | "group" | "test";
354
320
  declare class TestAction {
355
321
  private readonly parent;
356
322
  private readonly name;
323
+ private readonly type;
357
324
  private readonly skip;
358
325
  private readonly action;
359
326
  private constructor();
360
- static create(parent: TestAction | undefined, name: string, skip: TestSkip | undefined, action: () => (void | Promise<void>)): TestAction;
327
+ static create(parent: TestAction | undefined, name: string, type: TestActionType, skip: TestSkip | undefined, action: () => (void | Promise<void>)): TestAction;
361
328
  getParent(): TestAction | undefined;
362
329
  getName(): string;
363
330
  getFullNameParts(): JavascriptIterable<string>;
364
331
  getFullName(): string;
332
+ getType(): TestActionType;
365
333
  getSkip(): TestSkip | undefined;
366
334
  shouldSkip(): boolean;
367
335
  getAction(): () => (void | Promise<void>);
368
336
  runAsync(): void | Promise<void>;
369
337
  }
370
338
 
339
+ declare class FailedTest {
340
+ private readonly testAction;
341
+ private readonly error;
342
+ private constructor();
343
+ static create(testAction: TestAction, error: unknown): FailedTest;
344
+ getTestAction(): TestAction;
345
+ getError(): unknown;
346
+ getErrorMessage(): string;
347
+ }
348
+
349
+ declare class SkippedTest {
350
+ private readonly skip;
351
+ private readonly testAction;
352
+ private constructor();
353
+ static create(skip: TestSkip, testAction: TestAction): SkippedTest;
354
+ getSkipMessage(): string;
355
+ getTestAction(): TestAction;
356
+ }
357
+
358
+ type ConsoleTestRunnerStyle = TestActionType | "passed" | "skipped" | "failed";
359
+ declare abstract class ConsoleTestRunnerUI {
360
+ private writeStream?;
361
+ private readonly styles;
362
+ protected constructor();
363
+ static flat(): FlatConsoleTestRunnerUI;
364
+ static tree(): TreeConsoleTestRunnerUI;
365
+ setWriteStream(writeStream: CharacterWriteStream): this;
366
+ setStyle(style: ConsoleTestRunnerStyle, styleFunction: (text: string) => string): this;
367
+ setStyles(styles: Partial<Record<ConsoleTestRunnerStyle, (text: string) => string>>): this;
368
+ private applyStyle;
369
+ protected addIndentation(): void;
370
+ protected removeIndentation(): void;
371
+ protected indent(action: () => number | void | PromiseLike<number | void>): AsyncResult<number>;
372
+ protected writeString(text: string): AsyncResult<number>;
373
+ protected writeLine(text?: string): AsyncResult<number>;
374
+ protected writeTestActionName(testAction: TestAction): AsyncResult<number>;
375
+ protected writeFullTestActionName(testAction: TestAction): AsyncResult<number>;
376
+ beforeTestGroup(testGroup: TestAction): AsyncResult<void>;
377
+ afterTestGroup(testGroup: TestAction): AsyncResult<void>;
378
+ beforeTest(testAction: TestAction): AsyncResult<void>;
379
+ afterPassedTest(testAction: TestAction): AsyncResult<void>;
380
+ afterSkippedTest(testAction: TestAction, skip: TestSkip): AsyncResult<void>;
381
+ afterFailedTest(currentTestAction: TestAction, error: unknown): AsyncResult<void>;
382
+ writeSummary(passedTestCount: number, skippedTests: Iterable<SkippedTest>, failedTests: Iterable<FailedTest>): AsyncResult<void>;
383
+ }
384
+ declare class FlatConsoleTestRunnerUI extends ConsoleTestRunnerUI {
385
+ protected constructor();
386
+ static create(): FlatConsoleTestRunnerUI;
387
+ beforeTest(testAction: TestAction): AsyncResult<void>;
388
+ }
389
+ declare class TreeConsoleTestRunnerUI extends ConsoleTestRunnerUI {
390
+ private testActions;
391
+ private testActionWrittenDepth;
392
+ protected constructor();
393
+ static create(): TreeConsoleTestRunnerUI;
394
+ beforeTestGroup(testGroup: TestAction): AsyncResult<void>;
395
+ afterTestGroup(testGroup: TestAction): AsyncResult<void>;
396
+ beforeTest(testAction: TestAction): AsyncResult<void>;
397
+ }
398
+
371
399
  type ConsoleTestFunction = (runner: ConsoleTestRunner) => (void | Promise<void>);
372
400
  type ConsoleTestFunctionContainer = {
373
401
  test: ConsoleTestFunction;
374
402
  };
375
- declare class ConsoleTestRunner extends TestRunner {
403
+ declare class ConsoleTestRunner implements TestRunner {
376
404
  private writeStream;
377
- private readonly pendingActions;
378
- private pendingActionsInsertIndex;
405
+ private readonly testActions;
406
+ private testActionInsertIndex;
379
407
  private currentTestAction;
380
408
  private currentTest;
381
409
  private passedTestCount;
382
410
  private readonly skippedTests;
383
411
  private readonly testFailures;
384
- constructor();
385
- static create(): ConsoleTestRunner;
412
+ private readonly ui;
413
+ constructor(ui?: ConsoleTestRunnerUI);
414
+ static create(ui?: ConsoleTestRunnerUI): ConsoleTestRunner;
386
415
  static run(testFunction: ConsoleTestFunction | ConsoleTestFunctionContainer): Promise<void>;
387
416
  static run(testFunctions: JavascriptIterable<ConsoleTestFunction | ConsoleTestFunctionContainer>): Promise<void>;
388
417
  setWriteStream(writeStream: CharacterWriteStream): this;
418
+ setStyle(style: ConsoleTestRunnerStyle, styleFunction: (text: string) => string): this;
419
+ setStyles(styles: Partial<Record<ConsoleTestRunnerStyle, (text: string) => string>>): this;
389
420
  /**
390
421
  * Get the number of {@link TestAction}s that have yet to be executed.
391
422
  */
392
- getPendingTestActionsCount(): number;
423
+ getTestActionCount(): number;
393
424
  /**
394
- * Get the index in the pending-{@link TestAction} stack that new {@link TestAction}s will be
425
+ * Get the index in the {@link TestAction} list that new {@link TestAction}s will be
395
426
  * inserted at.
396
427
  */
397
- getPendingTestActionsInsertIndex(): number;
428
+ getTestActionInsertIndex(): number;
429
+ private resetTestActionInsertIndex;
430
+ private insertTestAction;
398
431
  /**
399
432
  * Get the number of tests that have been skipped.
400
433
  */
@@ -413,16 +446,31 @@ declare class ConsoleTestRunner extends TestRunner {
413
446
  getCurrentTestAction(): TestAction | undefined;
414
447
  getCurrentTest(): Test | undefined;
415
448
  private assertNoCurrentTest;
416
- beforeTest(fullTestNameParts: JavascriptIterable<string>): PromiseAsyncResult<void>;
417
- afterPassedTest(): PromiseAsyncResult<void>;
418
- afterSkippedTest(fullTestNameParts: JavascriptIterable<string>, skip: TestSkip | undefined): PromiseAsyncResult<void>;
419
- afterFailedTest(fullTestNameParts: JavascriptIterable<string>, error: unknown): PromiseAsyncResult<void>;
449
+ beforeTestGroup(testAction: TestAction): AsyncResult<void>;
450
+ afterTestGroup(testAction: TestAction): AsyncResult<void>;
451
+ beforeTest(testAction: TestAction): AsyncResult<void>;
452
+ afterPassedTest(testAction: TestAction): AsyncResult<void>;
453
+ afterSkippedTest(testAction: TestAction, skip: TestSkip): AsyncResult<void>;
454
+ afterFailedTest(testAction: TestAction, error: unknown): AsyncResult<void>;
455
+ andList(values: unknown[] | Iterable<unknown>): string;
456
+ toString(value: unknown): string;
457
+ skip(message?: string): TestSkip;
458
+ skip(shouldSkip: boolean, message?: string): TestSkip;
459
+ testFile(fileName: string, testAction: (() => void) | ((test: Test) => void)): void;
460
+ testFile(fileName: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
461
+ testType(typeNameOrType: string | Type<unknown>, testAction: (() => void) | ((test: Test) => void)): void;
462
+ testType(typeNameOrType: string | Type<unknown>, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
463
+ testFunction(functionSignature: string, testAction: (() => void) | ((test: Test) => void)): void;
464
+ testFunction(functionSignature: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
420
465
  testGroup(testGroupName: string, testAction: () => (void | Promise<void>)): void;
421
466
  testGroup(testGroupName: string, skip: TestSkip | undefined, testAction: () => (void | Promise<void>)): void;
422
467
  test(testName: string, testAction: (test: Test) => (void | Promise<void>)): void;
423
468
  test(testName: string, skip: TestSkip | undefined, testAction: (test: Test) => (void | Promise<void>)): void;
469
+ private innerTestGroup;
470
+ private innerTest;
471
+ private testGroupOrTest;
424
472
  runAsync(): Promise<void>;
425
- printSummary(): PromiseAsyncResult<void>;
473
+ printSummary(): AsyncResult<void>;
426
474
  }
427
475
 
428
- export { AssertTest, BasicTestSkip, type ConsoleTestFunction, type ConsoleTestFunctionContainer, ConsoleTestRunner, FailedTest, SkippedTest, Test, TestAction, TestRunner, TestSkip, test };
476
+ export { AssertTest, BasicTestSkip, type ConsoleTestFunction, type ConsoleTestFunctionContainer, ConsoleTestRunner, FailedTest, SkippedTest, Test, TestAction, type TestActionType, TestRunner, TestSkip, test };
@@ -9,8 +9,8 @@ import {
9
9
  TestRunner,
10
10
  TestSkip,
11
11
  test
12
- } from "./chunk-CHBOMCYM.js";
13
- import "./chunk-5Z677JON.js";
12
+ } from "./chunk-VF6FBNAU.js";
13
+ import "./chunk-MMAX3IZF.js";
14
14
  export {
15
15
  AssertTest,
16
16
  BasicTestSkip,