Equivalent to calling vitest.expect(arg).toBeDefined() while also asserting arg to be defined.
vitest.expect(arg).toBeDefined()
arg
The type of arg.
The variable to be asserted.
undefined.
undefined
arg is not undefined.
const iAmDefined: number | undefined = Math.random() < 1 ? 10 : undefined;expectToBeDefined(iAmDefined);expect(iAmDefined + 1).toBe(11); Copy
const iAmDefined: number | undefined = Math.random() < 1 ? 10 : undefined;expectToBeDefined(iAmDefined);expect(iAmDefined + 1).toBe(11);
Equivalent to calling
vitest.expect(arg).toBeDefined()
while also assertingarg
to be defined.