Determine if your number is not a number
As the joke goes...
typeof NaN === "number"
... as in, the NaN float value is considered a number. However, toBe assertions will fail if you try to expect some value toBe(NaN) . This assertion will provide proof that your actual value is, in fact, a NaN value.
expect(NaN).toBeNaN(); // passes
expect(1.0).not.toBeNaN(); // passes
// compile time error, will be reported when the suite is run
expect(new Vec3()).not.toBeNaN();
If this method is called with anything other than a f32 | f64 type, it will result in a compile time error.
This method is safe to use with jest portably.
Copy link