O'Reilly logo

Mastering PhoneGap Mobile Application Development by Kerri Shotts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing tests using Chai

Chai is an assertion library. Instead of needing to write several variations of assert, Chai provides several different methods that we can use to create tests that are easy to read. Chai also uses method chaining to create a more English-like version of the test, so they are both easy to read and write.

Note

For more information on Chai, visit http://www.chaijs.com.

Chai is useful because it allows us to write expressive tests without a lot of work. It also caters to you, the developer, by letting you choose one of several provided interfaces. There are three:

  • assert: Tests use an assert-styled interface, akin to what we used in the prior section. There are a lot of utility methods that you can use, such as assert.typeOf ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required