CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Assert.equal not returning properly

Open fabioel opened this issue 10 years ago • 5 comments

Hi @DavertMik!

Since updating to v0.3.0 I am having problems with assert.equal when the assert fails:

Here a little code snippet to show what I mean:

Before((I) => {
I.amOnPage('/');
});

 Scenario.only(
   'Navigating to prev week check date picker value',
    function* prev(I, actionBarTop, appointmentPage) {
    assert.equal(true, false);
});
Navigation --
 Navigating to prev week check date picker value
 • I am on page "https://www.test.com"

and after that the test just finishes, without failing properly

On the otherhand with assert.equal(true, true) the tests passes

Is there some problem with assert?

UPDATE: I have got the impression that is has to do with your new handling of errors in the scenario.js: Line 22: recorder.add(() => done(err), true);

Might be the issue?

fabioel avatar Mar 23 '16 08:03 fabioel

I have got the impression that is has to do with your new handling of errors in the scenario.js

That maybe it. It was important to make promise-based assertions work, didn't check for non-promises

DavertMik avatar Mar 23 '16 12:03 DavertMik

This is pretty rare case, as if you

a) not using generator function b) use yield before performing assertion

everything works fine. Anyway, going to fix that

DavertMik avatar Mar 23 '16 13:03 DavertMik

Also hitting this. It seems worse than this description, though: no assertions work after the 1st yield. So it doesn't work under any circumstance where you've queried the page for data and need to assert its value.

acthp avatar May 01 '16 01:05 acthp

I've had similar symptoms with custom helpers. The when the test passes the message is OK, if it fails I get no feedback with errors.

rezen avatar Jun 14 '16 22:06 rezen

Tested in v0.6.3

Before((I, authPage) => {
   I.amOnPage(authPage.url);
});

Scenario.only('foo test', function*(I) {
    var bla = yield I.grabTextFrom('//button')
    assert.equal(bla, 'foo');
});


'Enter' == 'foo'
      + expected - actual

      -Enter
      +foo

Everything works as expected. Closing this issue

APshenkin avatar Jun 01 '17 07:06 APshenkin