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

assert.reTest? #11

Closed
sindresorhus opened this issue Nov 27, 2014 · 2 comments
Closed

assert.reTest? #11

sindresorhus opened this issue Nov 27, 2014 · 2 comments
Labels
enhancement new functionality question

Comments

@sindresorhus
Copy link
Member

I've found I very often need to assert something using a regex .test().

I currently do:

assert(/markdown-body/.test(css));

But if that fails the error message isn't very helpful.

I could include css in the second argument, but I still wouldn't know what the regex was.

Could maybe be useful to have an assertion method for this:

assert.reTest(/markdown-body/, css);

Which on failure would print the regex and the full content of css.

Needs a better name. And probably needs a .notReTest too.

@kevva thoughts?

@sindresorhus sindresorhus added enhancement new functionality question labels Nov 27, 2014
@kevva
Copy link
Contributor

kevva commented Nov 28, 2014

Wish this could be in .true() and .false() but it might be hard to have a second optional argument with msg being a string too.

But I'm +1 for this. We can change the name later on.

@kevva
Copy link
Contributor

kevva commented Apr 22, 2015

Sort of closed in kevva/claim@7e2270a.

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

No branches or pull requests

2 participants