Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to show descriptive text if a test fail? #129

Open
ibc opened this issue Feb 18, 2015 · 4 comments
Open

Is it possible to show descriptive text if a test fail? #129

ibc opened this issue Feb 18, 2015 · 4 comments

Comments

@ibc
Copy link

ibc commented Feb 18, 2015

Example:

expect(fn, 'should not throw').to.not.throwException();

It could be the second argument of expect().

@derwok
Copy link

derwok commented May 21, 2016

I second this and add the following use scenario: For example for multiple very similar checks the time & coding effort is reduced by checking with multiple expect() in one test case like this:

        browser.setValue('input[id="id_meetingproject"]', "");  // empty input
        browser.setValue('input[id="id_meetingname"]', "");     // empty input
        browser.click("#btnMeetingSeriesSave");     // try to save
        expect(browser.isVisible("#btnMeetingSeriesSave")).to.be.true;  // dialog still open!

        browser.setValue('input[id="id_meetingproject"]', "XXX");
        browser.setValue('input[id="id_meetingname"]', "");     // empty input
        browser.click("#btnMeetingSeriesSave");     // try to save
        expect(browser.isVisible("#btnMeetingSeriesSave")).to.be.true;  // dialog still open!

        browser.setValue('input[id="id_meetingproject"]', "");  // empty input
        browser.setValue('input[id="id_meetingname"]', "XXX");
        browser.click("#btnMeetingSeriesSave");     // try to save
        expect(browser.isVisible("#btnMeetingSeriesSave")).to.be.true;  // dialog still open!

If one of these expect() fails, you only see this in the console:

Uncaught AssertionError: expected true to be false

It would be great to find out which expect() did fail with a small message...

@FlorianWendelborn
Copy link

@derwok does that example currently work? I'm kind of surprised that to.be.true is able to do anything without ().

@derwok
Copy link

derwok commented May 23, 2016

Sorry - i was using "chai" expect() and was thinking I use this exepct() package.
With chai I can add a descriptive message to any expect().
Plus some more cool fetures (like ommiting the parantheses behind any .to.be.true etc.)
So for me the issue is solved. ;-)

@FlorianWendelborn
Copy link

@derwok still surprised that chai manages to execute the command without ().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants