Documentation Index
Fetch the curated documentation index at: https://grafana_com_website/llms.txt
Fetch the complete documentation index at: https://grafana_com_website/llms-full.txt
Use this file to discover all available pages before exploring further.
STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: /docs/k6/next/javascript-api/jslib/testing/non-retrying-assertions/tobetruthy.md (append .md) or send Accept: text/markdown to /docs/k6/next/javascript-api/jslib/testing/non-retrying-assertions/tobetruthy/. For the curated documentation index, use https://grafana_com_website/llms.txt. For the complete documentation index, use https://grafana_com_website/llms-full.txt.
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
toBeTruthy()
The toBeTruthy() method asserts that a value is truthy in JavaScript. A value is truthy if it converts to true when evaluated in a boolean context.
Syntax
expect(actual).toBeTruthy();
expect(actual).not.toBeTruthy();Returns
| Type | Description |
|---|---|
| void | No return value |
Description
The toBeTruthy() method checks if a value is truthy. In JavaScript, all values are truthy except for the following falsy values:
false0-00n(BigInt)""(empty string)nullundefinedNaN
Usage
import { expect } from 'https://jslib.k6.io/k6-testing/0.6.1/index.js';
export default function () {
expect(true).toBeTruthy();
expect(1).toBeTruthy();
expect(-1).toBeTruthy();
expect('hello').toBeTruthy();
expect(' ').toBeTruthy(); // Non-empty string
expect(42).toBeTruthy();
expect(3.14).toBeTruthy();
expect(Infinity).toBeTruthy();
expect(-Infinity).toBeTruthy();
}Was this page helpful?
Related resources from Grafana Labs

