β‘
β‘
β‘
β‘
as-pect
Searchβ¦
β‘
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
Powered By
GitBook
π©βπ« 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,
1
// true is truthy!
2
expect
(
true
).
toBeTruthy
();
3
β
4
// a reference is always truthy, unless it's null
5
expect
(
new
Vec3
(
1
,
2
,
3
)).
toBeTruthy
();
6
β
7
// 1 is truthy
8
expect
(
1
).
toBeTruthy
();
9
β
10
// strings with values are always truthy
11
expect
(
"Something!"
).
toBeTruthy
();
12
β
13
// false is falsy
14
expect
(
false
).
toBeFalsy
();
15
β
16
// null is falsy
17
expect
<
Vec3
|
null
>
(
null
).
toBeFalsy
();
18
β
19
// 0 is falsy
20
expect
(
0
).
toBeFalsy
();
21
β
22
// NaN is always falsy
23
expect
(
NaN
).
toBeFalsy
();
24
β
25
// empty strings are falsy
26
expect
(
""
).
toBeFalsy
();
Copied!
These methods are safe to use with
jest
.
Previous
toBlockEqual
Next
toBeNaN
Last modified
2yr ago
Copy link