Last active
August 29, 2015 13:55
-
-
Save marcusoftnet/8768076 to your computer and use it in GitHub Desktop.
should to check for null
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var should = require("should"); | |
var myObject = null; | |
// DON’T | |
// this will fail with a "TypeError: Cannot read property 'should' of null" error | |
myObject.should.exsist(); | |
// DO | |
// this is the proper way of writing an assertion for null | |
should.not.exists(myObject); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment