javascriptnode.jschaishould.js

ChaiJS Should - test for empty string


According to docs on the shouldJS site I should be able to do this:

''.should.be.empty();

The ChaiJS site doesn't have an example with should syntax, but it lists it for expect and it seems that the above example would work.

However this yields:

TypeError: Property 'empty' of object #<Assertion> is not a function

What is syntax for the Chai lib empty() with should style?


Solution

  • Just remove the parens - instead of empty(), use empty:

    ''.should.be.empty;
    

    Further Reading: Docs on Empty