โšก
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
  2. ๐Ÿคทโ€โ™€๏ธ Expectations

๐Ÿ‘ฉโ€๐Ÿซ toBeTruthy and toBeFalsy

Tell the truthy, or at least don't falsy.

These comparisons are used to determine if a value is truthy or falsy in the JavaScript sense. In JavaScript there are only six falsy values:

  • false

  • 0

  • ""

  • null

  • undefined

  • NaN

In AssemblyScript, there is no undefined, so as-pect will treat each of those values as falsy. Truthy values are anything that is not falsy,

// true is truthy!
expect(true).toBeTruthy();

// a reference is always truthy, unless it's null
expect(new Vec3(1, 2, 3)).toBeTruthy();

// 1 is truthy
expect(1).toBeTruthy();

// strings with values are always truthy
expect("Something!").toBeTruthy();

// false is falsy
expect(false).toBeFalsy();

// null is falsy
expect<Vec3 | null>(null).toBeFalsy();

// 0 is falsy
expect(0).toBeFalsy();

// NaN is always falsy
expect(NaN).toBeFalsy();

// empty strings are falsy
expect("").toBeFalsy();

These methods are safe to use with jest.

PrevioustoBlockEqualNexttoBeNaN

Last updated 5 years ago

Was this helpful?

๐Ÿ—๏ธ