-
Notifications
You must be signed in to change notification settings - Fork 669
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
[Suggestions] Some syntactic sugar and extensions #285
Comments
If you do Can you explain I think |
All but contains(Foo, Bar) and containsAny(Foo, Bar) are already there.
What I’m suggesting are syntactic sugar or wrappers to make the exp better.
…On Thu, Dec 21, 2017 at 01:19 Lachlan ***@***.***> wrote:
If you do wrapper.trigger('click'), that already works (triggers on
component root element).
Can you explain contains a little more and give an example of what you'd
want to write? At the moment I write
expect(wrapper.findAll(ChannelUsersModalUser)).toHaveLength(2) which
seems okay.
I think has could be added.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#285 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHrt0kO9Aa9ns8FgqpDXnBztrNxlnTKCks5tCaQigaJpZM4RJGaq>
.
|
On the other hand, I intentionally put “has” at the bottom of the list
because I don’t have very strong opinion about it — when I think it’s a
good alias, I can still live without it.
…On Thu, Dec 21, 2017 at 09:01 An Phan ***@***.***> wrote:
All but contains(Foo, Bar) and containsAny(Foo, Bar) are already there.
What I’m suggesting are syntactic sugar or wrappers to make the exp better.
On Thu, Dec 21, 2017 at 01:19 Lachlan ***@***.***> wrote:
> If you do wrapper.trigger('click'), that already works (triggers on
> component root element).
>
> Can you explain contains a little more and give an example of what you'd
> want to write? At the moment I write
> expect(wrapper.findAll(ChannelUsersModalUser)).toHaveLength(2) which
> seems okay.
>
> I think has could be added.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#285 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AHrt0kO9Aa9ns8FgqpDXnBztrNxlnTKCks5tCaQigaJpZM4RJGaq>
> .
>
|
IMHO, |
I agree with @38elements - if I thought about this a bit more and I'm generally against this kinds of things - I think being explicit and easily understood in your tests is a worth the extra typing (or just make a snippet, most IDE/editors have that support). |
Aliases don’t add more APIs to remember. If anything, quite the opposite –
they make things easier because _we don’t have to remember_. For example,
top off your head can you remember which of lodash’s `extends` and
`assigns` is an alias of which? Yet we don’t care, and just naturally use
any of them. Libraries like PHPUnit, mockery, sinon etc. also have nice
syntactic sugars e.g. `onFirstCall()`, `onSecondCall()`, `receiveOnce` etc
whose functionalities can already be covered by other "original" methods,
and those are what make the difference – I can't think of, or use, anything
mockery does that normal PHPUnit mock can't, but I still pick mockery any
day simply because the syntax is much more fluent.
While I do understand why people are against aliases (I’m among them, trust
me), there are some that I do believe would make our lives easier and a
framework/lib more fluent/friendly, otherwise I wouldn’t be suggesting
them.
…On Fri, Dec 22, 2017 at 06:54 Lachlan ***@***.***> wrote:
I agree with @38elements <https://github.com/38elements> - if has is more
popular, we should depreciate contains. Aliases just add more API to
remember. People can add them to their own projects easily enough.
I thought about this a bit more and I'm generally against this kinds of
things - I think being explicit and easily understood in your tests is a
worth the extra typing (or just make a snippet, most IDE/editors have that
support).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#285 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHrt0l4Cbo2VJoESxR2L4VV5aQO1EE-Vks5tC0QwgaJpZM4RJGaq>
.
|
If I might add one more to the discussion; we currently have |
@robcresswell You can get the id value using the wrapper.attributes().id |
@eddyerburgh Yep I know, I put that in my original comment; it was just a "sugar" suggestion. |
@robcresswell Can't say I'm using |
(Sorry @robcresswell, I didn't see that extra My opinion is that we should avoiding adding direct aliases, like The API list is already large. Adding aliases will make it more difficult to browse. I'm also not fond of adding helper methods like The more methods there are, the more maintenance there is, and the more opportunity there is for methods to get out of sync. That said, there are some good suggestions in this thread, like I'm going to close this issue as there are too many discussion points. It will be easier to discuss these feature requests if each feature request has its own issue. I'll start a new issue about extending |
@eddyerburgh While I understand and tend to agree with some of your reasons, not adding APIs because the list is already large or because there will be more maintenance is IMO not a strong enough argument.
That said, I do agree that there are too many discussion points – my intention was similar to a wishlist. Will create issues/PRs once I have time i.e. back from vacation. |
@phanan I tend to use @eddyerburgh That approach is reasonable, I can understand wanting to keep maintenance low and the API clean. Thanks for weighing in. |
So I've been playing around with the lib for a while and often find myself wishing for some helpers/wrappers that feel a little bit more fluent e.g.:
wrapper.find(Foo).click()
as a syntactic sugar forwrapper.find(Foo).trigger('click')
. Maybe we can even go as far aswrapper.click(Foo)
?contains(Foo, Bar, Baz)
containsAny(Foo, Bar, Baz)
has()
as an alias forcontains()
id()
forattributes().id()
@robcresswellWhat do you guys think?
The text was updated successfully, but these errors were encountered: