You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I use a function reference in my beforeEach(...), and that function throws an error, the test continues to execute as-if there was no problem. In some cases, this skips the it(...) blocks from executing altogether without throwing any indication that something wrong happened.
ie. a case like this:
var myVariable;
beforeEach(setupMyTest);
it('Should be equal to "fail" string', function () {
expect(myVariable).toEqual('fail');
});
///
function setupMyTest () {
myVariable = fail;
}
Where-as if I use a function block, the error is echoed to console and shows the tests as failed:
var myVariable;
beforeEach(function () {
myVariable = fail;
});
it('Should be equal to "fail" string', function () {
expect(myVariable).toEqual('fail');
});
I use the first pattern for writing tests because it is much cleaner to read and follow, when there is a large series of tests. But there are cases where a bug goes undetected as a result of the error being silenced.
The text was updated successfully, but these errors were encountered:
If I use a function reference in my
beforeEach(...)
, and that function throws an error, the test continues to execute as-if there was no problem. In some cases, this skips theit(...)
blocks from executing altogether without throwing any indication that something wrong happened.ie. a case like this:
Where-as if I use a function block, the error is echoed to console and shows the tests as failed:
I use the first pattern for writing tests because it is much cleaner to read and follow, when there is a large series of tests. But there are cases where a bug goes undetected as a result of the error being silenced.
The text was updated successfully, but these errors were encountered: