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

Allow destructuring of assertions #551

Closed
kl0tl opened this issue Feb 14, 2016 · 11 comments
Closed

Allow destructuring of assertions #551

kl0tl opened this issue Feb 14, 2016 · 11 comments
Labels

Comments

@kl0tl
Copy link

kl0tl commented Feb 14, 2016

Bound methods would allow to destructure assertions while waiting for something like tc39/proposal-bind-operator#5 to happen.

import test from 'ava';

test(({ same }) => {
    same([1, 2], [1, 2]);
});
@sindresorhus
Copy link
Member

Why would you use that? It's more verbose than t.same().

@kl0tl
Copy link
Author

kl0tl commented Feb 14, 2016

For a single assertion yes, but it would be a nicer when multiple assertions are used multiple times in the same test.

@kl0tl
Copy link
Author

kl0tl commented Feb 14, 2016

And while this test is trivial I like how it makes immediately clear what assertions I'm using.

@sindresorhus
Copy link
Member

We'll consider it, but this honestly feels like just using a new language feature for the sake of it, rather than actually being beneficial. It also IMHO makes tests look more noisy and inconsistent.

And while this test is trivial I like how it makes immediately clear what assertions I'm using.

I don't see any benefit of knowing that up front.

@sindresorhus sindresorhus added the enhancement new functionality label Feb 14, 2016
@sindresorhus sindresorhus changed the title Bind Test methods ? Allow destructuring of assertions Feb 14, 2016
@kl0tl
Copy link
Author

kl0tl commented Feb 14, 2016

I may have been too used to it. Anyway, it means losing the power-assert output while #550 is pending.

@briandipalma
Copy link

id-length warnings in ESLint are triggered by t so it would be handy if we could use destructuring as a way to silence those.

@jamestalmage
Copy link
Contributor

id-length warnings in ESLint are triggered by t so it would be handy if we could use destructuring as a way to silence those.

Add t to the exceptions property: http://eslint.org/docs/rules/id-length#exceptions

@jamestalmage
Copy link
Contributor

I think this should just be closed. Allowing this would require significant effort for power-assert, our codemods, and linter. All to allow something of dubious value.

@briandipalma
Copy link

Any chance we could import the assertion functions from ava so there is no need for the t reference?

@jamestalmage
Copy link
Contributor

Any chance we could import the assertion functions from ava so there is no need for the t reference?

No, the t reference is specific to that particular test. We keep track of the assertion count, so you can use t.plan

@novemberborn
Copy link
Member

novemberborn commented Jun 19, 2016

Destructuring t for each test you write seems cumbersome.

From the id-length description:

Very short identifier names like e, x, _t or very long ones like hashGeneratorResultOutputContainerObject can make code harder to read and potentially less maintainable.

I don't think that applies to AVA tests.


Closing this because the effort required isn't worthwhile.

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

No branches or pull requests

5 participants