David Rodenas PhD
1 min readJul 9, 2023

--

In addition to the clarification of Christopher, who clearly had similar experience to mine, I had found a lot of tests here and there without any expect. :(

And it is almost unbelievable, because even when the CI verifies that all the tests have expectations, developers still manage not to do any assertion at all. That is because they write assertions that never fail, something like:

expect(true).toBe(true);

Well, that is extreme -although I had found it a couple of times- they often do something equivalent but harder to catch. For example, when using Enzyme to test React, it is quite easy to find some jewels like:

expect(wrapper.find('.say-hello')).not.toBe(null);

In which, because wrapper.find always return a non null object, it always passes. Even when the element is not present.

You may wonder how it happens, well, that is because developers wrote those tests after the code, and they did not even bother to verify that the tests were working properly... but the code is covered, so they deliver, and next.

Thanks Stewno1 for the opportunity for the clarification!!

--

--

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.

Responses (1)