expects to be passed the context from an executing Vitest task (i.e. the ctx argument)

NOTE:

the Vitest ctx context is only available when tests are written using

it('description', function(ctx) {...})

or it('description', (ctx) => {...})

and not when using

it('description', () => {...})

or it('description', function() => {...})

Param

the ctx context object passed to a Vitest it

Hierarchy

  • AftTest
    • AftVitestTest

Constructors

Properties

description: string
test: Test<{}>

an instance of a Vitest.Context from the ctx context passed to a Vitest it function as an argument ctx

NOTE:

if no ctx argument is passed to your it function this will not be available

Type declaration

    Accessors

    • get aftCfg(): AftConfig
    • Returns AftConfig

    • get buildInfoManager(): BuildInfoManager
    • a BuildInfoManager instance used to generate a Build Number and Build Name from the first loaded BuildInfoPlugin

      Returns BuildInfoManager

    • get elapsed(): number
    • returns the amount of time, in milliseconds, elapsed since the AftTest was started either by calling the run function or using aftTest(description, testFunction, options) helper function until it ended or now if not yet done

      NOTE

      this includes the time taken to query any PolicyPlugin instances

      Returns number

    • get policyManager(): PolicyManager
    • a PolicyManager instance used to determine if this AftTest should run by querying all loaded PolicyPlugin instances

      Returns PolicyManager

    • get reporter(): ReportingManager
    • a ReportingManager that uses the description property of this AftTest as the name or the ReportingManager passed in via AftTestOptions

      Returns ReportingManager

    • get results(): TestResult[]
    • returns an array of TestResult objects for each result already submitted via a call to verify, pass, fail or pending or the completion of the testFunction execution within the run function

      NOTE:

      one result is submitted for each associated Test ID or just one overall result if no Test IDs are associated with this instance if withFileSystemCache is enabled this includes searching the filesystem cache for any logged test results for the AftTest.description and returning the results as an array of TestResult objects with each object corresponding to a Test ID referenced in the test name

      Returns TestResult[]

      an array of TestResult objects where each entry corresponds to a referenced Test ID parsed from the AftTest.description

    • get status(): TestStatus
    • returns the overall status of this AftTest. this value is only updated when a AftTest.fail(...) call is made or a AftTest.verify(actual, expected) check fails or when the test completes without error. otherwise the value will be 'untested'

      Returns TestStatus

    • get testIds(): string[]
    • an array of string values representing the associated test IDs for this AftTest. for each test ID a unique result can and will be reported during or on the completion of running the testFunction

      ex: ["C1234", "C2345"]

      Returns string[]

    Methods

    • Returns Promise<void>

    • Parameters

      • status: TestStatus
      • resultMessage: string
      • Optional testId: string

      Returns Promise<TestResult>

    • Parameters

      • status: TestStatus
      • logMessage: string
      • Rest ...testIds: string[]

      Returns Promise<TestResult[]>

    • Parameters

      • status: TestStatus
      • Optional message: string

      Returns Promise<void>

    • Parameters

      • Optional options: AftTestOptions

      Returns AftTestOptions

    • Returns Promise<void>

    • Parameters

      • status: TestStatus
      • Optional message: string

      Returns Promise<void>

    • creates TestResult objects for each testId and sends these to the ReportingManager.submitResult function

      Parameters

      • status: TestStatus
      • Optional message: string
      • Rest ...testIds: string[]

      Returns Promise<void>

    • Parameters

      • testId: string

      Returns boolean

    • executes any 'fail' event actions after submitting a 'failed' result for each associated test ID and then throws a AftTestFailError to halt execution of the testFunction (if running)

      Parameters

      • Optional message: string

        an optional message to describe why the test is being marked as 'failed'

      Returns Promise<void>

      Default

      "unknown error occurred"
      
    • executes any 'pass' event actions after submitting a 'passed' result for each associated test ID and then throws a AftTestPassError to halt execution of the testFunction (if running)

      Returns Promise<void>

    • this function handles event actions and checking the PolicyManager to determine if the supplied testFunction should be run. immediately prior to executing the testFunction the _started function is called followed by execution of the testFunction and then calling _done

      NOTE

      if using the aftTest helper function then run is automatically called, otherwise it must manually be called to run the testFunction

      Returns Promise<AftVitestTest>

      this AftTest instance

    • checks if any of the supplied test ids should be run and returns true if at least one of them should

      Returns Promise<ProcessingResult<boolean>>

      a ProcessingResult<boolean> indicating if the testing should proceed

    • performs a comparison of an actual and expected result. by default any error will result in halting the execution of the AftTest and reporting a failure, but by setting the haltOnVerifyFailure option to false you can allow the test execution to continue and only report the failure at the completion of running the testFunction

      ex:

      // no message and continues on verify failure
      await aftTest('continue on failure', async (v: AftTest) => {
      await v.verify(true, false);
      // below will run because "haltOnVerifyFailure" is "false"
      // but overall status will be 'failed' because above
      // call fails
      await v.verify(true, true);
      }, {haltOnVerifyFailure: false});

      // message with test ID (failure)
      await aftTest('[C1234] error on failure', async (v: AftTest) => {
      // submits `TestResult` for test ID `C1234` with `status='failed'`
      // and `message="C1234 - expected 'false' to be 'true'"`
      await v.verify(true, false, '[C1234]');
      });

      // message with test ID (success)
      await aftTest('[C1234] successful test', async (v: AftTest) => {
      // submits `TestResult` for test ID `C1234` with `status='passed'`
      await v.verify(true, true, '[C1234]');
      });

      Parameters

      • actual: any

        the actual result from some action

      • expected: any

        the expected result from the action

      • Optional message: string

        an optional message to include before any error string when a failure occurs. this may also include any test ID(s) in the form "...[TestID]..." and if included will result in a call to pass or fail with the associated test ID(s)

      Returns Promise<ProcessingResult<boolean>>

      a ProcessingResult<boolean> where ProcessingResult.result === true equates to success and ProcessingResult.result !== true equates to failure.

      NOTE:

      if a message argument is passed to the verify call then it will be included in the message property of the returned ProcessingResult

    Generated using TypeDoc