💼 This rule is enabled in the ✅ recommended
config.
Translations: Français
t.true()
and t.false()
are stricter in their checks than t.truthy()
and t.falsy
.
For example: if you have a function foo()
which normally returns true
, but suddenly returns 1
instead, t.truthy(foo())
would not catch the change, but t.true(foo())
would.
This rule enforces the use of the former when the tested expression is known to result in a boolean value.
const ava = require('ava');
test('foo', t => {
t.truthy(value < 2);
t.truthy(value === 1);
t.truthy([1, 2, 3].includes(value));
t.falsy(!value);
t.truthy(!!value);
t.truthy(Array.isArray(value));
});
const ava = require('ava');
test('foo', t => {
t.true(value < 2);
t.true(value === 1);
t.true([1, 2, 3].includes(value));
t.false(!value);
t.true(!!value);
t.true(Array.isArray(value));
});