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

Add support for regex's with should-throw? #142

Open
lgastako opened this issue Oct 8, 2015 · 0 comments
Open

Add support for regex's with should-throw? #142

lgastako opened this issue Oct 8, 2015 · 0 comments

Comments

@lgastako
Copy link

lgastako commented Oct 8, 2015

Hi,

I have a situation where are tests are sometimes run under phantom 1.x and sometimes under 2.x. I have to check for a specific exception message being thrown but the exact message depends on which version of phantom, e.g.:

(def phantom-1.x-undef-err-msg "'undefined' is not a function (evaluating 'window.foo()')")
(def phantom-2.x-undef-err-msg "undefined is not a constructor (evaluating 'window.foo()')")

It would be great to be able to pass a regex instead of a string to should-throw then I could just definte one regex something like .*undefined.*is not a .* evaluating ('window.foo()').

I've also run into cases in the past where the exceptions thrown by a library outside of my control would use messages that included details like IP addresses or other values that could vary from environment to environment. Previously I just skipped checking the messages for these exceptions but that was not ideal.

I would be happy to take a shot at a PR if it would be welcomed.

Let me know what you think. Thanks.

@lgastako lgastako changed the title Add support regex's with should-throw? Add support for regex's with should-throw? Oct 8, 2015
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

1 participant