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

Provide guidance on the use of before() vs beforeEach() #25

Open
notmessenger opened this issue Apr 10, 2017 · 1 comment
Open

Provide guidance on the use of before() vs beforeEach() #25

notmessenger opened this issue Apr 10, 2017 · 1 comment

Comments

@notmessenger
Copy link
Contributor

before() is handy to use in situations where there is setup and rendering that needs to occur but then you have several separate it()/expect() calls that verify the same data. Rather than using a beforeEach() which performs this setup each time a before() may be a better choice so the setup only has to occur once.

Yes, these two methods, and others, are listed in the Mocha user guides but before() is not often used in our codebases so the pattern is not one developers are easily made aware of without being familiar with Mocha's abilities (which, yes, in a perfect world, they would be)

@notmessenger
Copy link
Contributor Author

Per comments from @job13er in a Slack conversation:

also, you need to be aware it won't work in integration tests
the setupComponentTest stuff is done in beforeEach (edited)
and so, if you use a top-level before in an integration test, the application/ember stuff isn't ready yet
you may be able to use a before in a nested describe in an integration test, but I can't confirm that

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