Menu
Choose a product
Viewing: v1.7.x (latest)
Find another version
Scroll for more
Open source
toBeFalsy()
The toBeFalsy() method asserts that a value is falsy in JavaScript. A value is falsy if it converts to false when evaluated in a boolean context.
Syntax
JavaScript
expect(actual).toBeFalsy();
expect(actual).not.toBeFalsy();Returns
| Type | Description |
|---|---|
| void | No return value |
Description
The toBeFalsy() method checks if a value is falsy. In JavaScript, the following values are falsy:
false0-00n(BigInt)""(empty string)nullundefinedNaN
All other values are truthy.
Usage
JavaScript
import { expect } from 'https://jslib.k6.io/k6-testing/0.6.1/index.js';
export default function () {
expect(false).toBeFalsy();
expect(0).toBeFalsy();
expect(-0).toBeFalsy();
expect(0n).toBeFalsy();
expect('').toBeFalsy();
expect(null).toBeFalsy();
expect(undefined).toBeFalsy();
expect(NaN).toBeFalsy();
}Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.