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

Make ViewFixture errors more useful #1513

Merged

Conversation

janhancic
Copy link
Contributor

Given this line in a test:

and("ticket.view.(.my-selector).text = 'XYZ'");

if no element was found for .my-selector, you would get this error message:

No view element found for "text"

After this change, you get this:

No view element found for "text". Processing property "(.my-selector).text" and looking for value "XYZ"

which is obviously much much better as it actually helps you pin point the location in the test where the problem is.

@sospirited
Copy link
Member

Completely for this item to be merged, it's one of those things that you can't appreciate good error messages until you have to get to the bottom of these types of issues.

Should be straight forward to add some UT coverage for this item too.

@janhancic
Copy link
Contributor Author

Also worth pointing out that you don't get a call stack when this failure happens, so it's really really hard to figure out what failed.

@dchambers
Copy link
Contributor

Thanks @janhancic.

@janhancic
Copy link
Contributor Author

👍

@thecapdan
Copy link
Contributor

@janhancic _verifyOnlyOneElementSelected is also used in the setup with 2 arguments. If the ViewFixture is setup with the wrong selector we would now get the following error:

'No view element found for 'badSelector'. Processing property '' and looking for value ''

We should either check for the additional args you added or provide a nice message for the case where it fails during setup

@janhancic
Copy link
Contributor Author

I missed that. I'll submit a fix.

if (elements.length === 0) {
throw 'No view element found for "' + selector + '"';
throw 'No view element found for "' + selector + '". Processing property "' + propertyName +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janhancic here 'selector' isn't a selector, its a view handler. Can you change the arg name to viewHandler

Jan Hancic added 2 commits September 10, 2015 14:50
…ill point you to what test line actually failed.
Only display the extra information if two new extra arguments are provided.
@janhancic janhancic force-pushed the feature/make-error-message-useful branch from b7db19b to c73dd11 Compare September 10, 2015 13:50
thecapdan added a commit that referenced this pull request Sep 10, 2015
…eful

Make ViewFixture errors more useful
@thecapdan thecapdan merged commit 4871435 into BladeRunnerJS:develop Sep 10, 2015
thecapdan added a commit that referenced this pull request Sep 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants