How to assert null with should
See original GitHub issueshould.be.null
throw an error saying should.be
doesn’t have this null
method.
How to transform the expect(null).to.be.null
to should
phrases?
Issue Analytics
- State:
- Created 11 years ago
- Reactions:7
- Comments:8 (4 by maintainers)
Top Results From Across the Web
AssertNull should be used or AssertNotNull - Stack Overflow
The assertNotNull() method means "a passed parameter must not be null ": if it is null then the test case fails. The assertNull()...
Read more >JUnit assertNull example - Java2Blog
Assertions.assertNull() checks that object is null. In case, object is not null, it will through AssertError. public static void assertNull(Object actual)
Read more >org.junit.Assert.assertNull java code examples - Tabnine
Asserts that an object isn't null. If it is an AssertionError is thrown with the given message. assertFalse · fail. Fails a test...
Read more >Assertion method Assert.assertNull() example. - Java2Novice
Assert class provides a set of assertion methods useful for writing tests. Assert.assertNull() methods checks that the object is null or not. If...
Read more >Expect / Should - Chai Assertion Library
Just because you can negate any assertion with .not doesn't mean you should. With great power comes great responsibility. It's often best to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, you have a couple of options…
I am assuming you are trying the following and its not working…
The should interface extends Object.prototype with the
should
keyword and sincenull
is not anObject
… etc.Here are a few of the alternatives, given that you have
var should = chai.should();
as opposed to just callingchai.should()
.In most cases the
not.exist
will likely work for you, especially if you are testing async callbacks in node.Hope that helps!
looks nice, too.