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

Recipe for moving from Mocha #558

Closed
sindresorhus opened this issue Feb 16, 2016 · 6 comments
Closed

Recipe for moving from Mocha #558

sindresorhus opened this issue Feb 16, 2016 · 6 comments

Comments

@sindresorhus
Copy link
Member

Most people already use Mocha and will need some guidance on how AVA is different and how to achieve the same thing with it. We should have a recipe for this.

Any Mocha converts interested in helping out with this?

@philmill
Copy link

I'm also coming from frameworks which use describe and context for organization. I'm wondering if something like Tape's t.test would suffice although contexts aren't tests.

I tried nesting a failing test within an empty test which just passes as an organizational experiment.

test('parent', (t) => {
  test('child', (tc) => {
    tc.fail();
  });
});

The lack of contexts is certainly not a deal breaker as the features presented with AVA are compelling enough for me to switch. But in regards to writing a recipe for Mocha converts, it might be difficult with the current API. Arguably if AVA forces me to write smaller test files which represent more narrowly focused context, that's probably a good thing.

@ghost
Copy link

ghost commented Feb 25, 2016

@philmill: Does that still happen if you do something like

test('parent', (t) => {
  test('child', (tc) => {
    tc.fail();
    t.end();
  });
});

?

@philmill
Copy link

Hey thanks for the suggestion @talexand, but the test still passes (results in infinite loop in call back mode). Also requiring calls to end() in callback mode isn't ideal.

To be clear, I'm not really suggesting this as a solution to organization. It's just the first thing I tried after looking over the available API and searching for others who have tried similar contextual organization in AVA. I'm thinking this isn't how tests are intended to be structured and possibly not on the road map either (which is fine).

@sindresorhus
Copy link
Member Author

Nested Unit Tests: An Anti-Pattern - https://twitter.com/kentcdodds/status/735502601119137793

// @kentcdodds

@jamestalmage
Copy link
Contributor

Nice! We should create an "Avoid beforeEach" recipe and link to that video!

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

No branches or pull requests

5 participants
@novemberborn @philmill @sindresorhus @jamestalmage and others