Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Unit Testing Behavior Driven Development with Mocha & Chai Test Suites and Test Specs (describe and it)

Alejandro Molina
Alejandro Molina
3,997 Points

Can someone explain expect(true).to.be.ok further?

What is the difference between using "ok" or "true" for the end of this expect function? I'm not fully understanding the "truthy" concept.

2 Answers

Steven Parker
Steven Parker
231,275 Points

True is a value, but .ok is a way to test for that value.

A value is considered "truthy" if it would satisfy an if statement. Most values are "truthy". The ones that are not are false, 0, an empty string (""), undefined, null and NaN.

Alejandro Molina
Alejandro Molina
3,997 Points

Ah I see. So it's just a way of making sure that a particular unit test is throwing valid data.