/** * A test result represents the result of an actor test that can either be passed or failed. * * Test results are immutable. */ export type TestResult = TestResultPassed | TestResultFailed; /** * Create a new test result that represents a passed value. * @param value The value the test passed with. */ export declare function passTest(value: T): TestResultPassed; /** * Create a new test result that represents a passed void value. */ export declare function passTestVoid(): TestResultPassed; /** * Create a new test result that represents a passed value with side data. * @param value The value the test passed with. * @param sideData Additional data to pass to the run phase. */ export declare function passTestWithSideData(value: T, sideData: S): TestResultPassed; /** * Create a new test result that represents a passed void value with side data. * @param sideData Additional data to pass to the run phase. */ export declare function passTestVoidWithSideData(sideData: TS): TestResultPassed; /** * Create a new test result that represents a test failure. * @param message The error message that describes the failure. */ export declare function failTest(message: string): TestResultFailed; /** * A passed test result. * This should not be constructed manually. * Instead, `testPass` should be used. */ export declare class TestResultPassed { protected readonly value: T; protected readonly sideData: TS; constructor(passValue: T, sideData: TS); /** * Check if the test has passed. * If true, it will contain a value. */ isPassed(): this is TestResultPassed; /** * Check if the test has failed. * If true, it will contain a failure message. */ isFailed(): this is TestResultFailed; /** * Get the value of the passed test, or undefined if the test failed. */ get(): T; /** * Get the value of the passed test, or throw an error if the test failed. */ getOrThrow(): T; /** * The side data that will be passed to run. */ getSideData(): TS; /** * Get the failure message callback of the failed test, or undefined if the test passed. */ getFailMessage(): undefined; /** * For passed tests, map the passed value to another value. * Failed tests will remain unchanged. * * This will not mutate the test result, and instead return a new test result. * * @param mapper A function that will transform the passed value. */ map(mapper: (value: T, sideData: TS) => T2): TestResultPassed; /** * For passed tests, asynchronously map the passed value to another value. * Failed tests will remain unchanged. * * This will not mutate the test result, and instead return a new test result. * * @param mapper A function that will transform the passed value. */ mapAsync(mapper: (value: T, sideData: TS) => Promise): Promise>; } /** * A failed test result. * This should not be constructed manually. * Instead, `testFail` should be used. */ export declare class TestResultFailed { protected readonly failMessage: string; constructor(failMessage: string); /** * Check if the test has passed. * If true, it will contain a value. */ isPassed(): this is TestResultPassed; /** * Check if the test has failed. * If true, it will contain a failure message. */ isFailed(): this is TestResultFailed; /** * Get the value of the passed test, or undefined if the test failed. */ get(): undefined; /** * Get the value of the passed test, or throw an error if the test failed. */ getOrThrow(): never; /** * The side data that will be passed to run. */ getSideData(): never; /** * Get the failure message callback of the failed test, or undefined if the test passed. */ getFailMessage(): string; /** * For passed tests, map the passed value to another value. * Failed tests will remain unchanged. * * This will not mutate the test result, and instead return a new test result. */ map(): TestResultFailed; /** * For passed tests, asynchronously map the passed value to another value. * Failed tests will remain unchanged. * * This will not mutate the test result, and instead return a new test result. */ mapAsync(): Promise; }