โšก
as-pect
  • โšกas-pect
  • ๐Ÿš€Getting Started
  • ๐Ÿ”งCLI Configuration
  • ๐Ÿ—๏ธAssemblyScript API
    • ๐Ÿ›๏ธTest Structure
    • ๐Ÿคทโ€โ™€๏ธ Expectations
      • ๐ŸŽญtoBe
      • ๐ŸคจtoStrictEqual
      • ๐ŸงฑtoBlockEqual
      • ๐Ÿ‘ฉโ€๐Ÿซ toBeTruthy and toBeFalsy
      • ๐Ÿ”ขtoBeNaN
      • ๐ŸšซtoBeNull
      • ๐ŸŒŒtoBeFinite
      • โšพtoThrow
      • โž•toBe(Greater|Less)Than
      • ๐Ÿ•ต๏ธโ€โ™€๏ธ toBeCloseTo
      • ๐Ÿ“toHaveLength
      • ๐ŸŽtoContain
      • ๐Ÿ“ฆtoContainEqual
      • โœ๏ธCustom Assertions
    • ๐ŸŽŸ๏ธTypes and Tooling
    • ๐Ÿช“Logging
    • ๐Ÿ‘ฉโ€๐Ÿ”ง RTrace and Memory Leaks
    • ๐Ÿ‘‰๐Ÿ‘ˆ Reflection
  • ๐ŸงถCore API
    • ๐ŸงชTestContext
    • ๐Ÿ‘ขBootstrap Tests Manually
    • ๐ŸŽ›๏ธTestGroup
    • โœ”๏ธTestResult
    • โœ๏ธReporters
      • ๐ŸฉณSummaryReporter
      • ๐Ÿ’ฌVerboseReporter
      • ๐ŸฅฝJSONReporter
      • ๐Ÿ—ƒ๏ธCSVReporter
Powered by GitBook
On this page

Was this helpful?

  1. AssemblyScript API

๐Ÿคทโ€โ™€๏ธ Expectations

What to expect(), when you're expecting!

There are a set of comparison functions defined in the types/as-pect.d.ts types definition. These comparison functions allow you to inspect object and memory state.

class Expectation<T> {
  constructor(public actual: T) {}
  not: Expectation<T>;
  // prototype methods follow
}

Expectations can be created like this:

// create an Expectation with typeof SomeValue`
expect(SomeValue);

Expectations can be negated like this:

// negate an assertion
expect(someValue).not.toBe(anotherValue);

// This assertion is effectively:
// I don't expect this value to be exactly this value

Calling the expect<T>(value: T) function outside of the following functions will result in unexpected behavior:

  • beforeEach()

  • afterEach()

  • beforeAll()

  • afterAll()

  • test()

  • it()

  • throws()

  • itThrows()

If this happens, the entire test suite will fail before it runs in the CLI, and the error description will be reported to the console.

PreviousTest StructureNexttoBe

Last updated 5 years ago

Was this helpful?

๐Ÿ—๏ธ