Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Change beforeEach to before #39

Open
jrschumacher opened this issue Jan 15, 2015 · 12 comments
Open

Change beforeEach to before #39

jrschumacher opened this issue Jan 15, 2015 · 12 comments

Comments

@jrschumacher
Copy link
Contributor

Per this conversation: https://groups.google.com/forum/?pli=1#!topic/loopbackjs/1F4H8sDw4-A

All helpers are using beforeEach which at least for me is quite counterintuitive since it would call each remote calls for each it. I ended up copying the helpers and making them use before and after which makes it really easy to have some kind of testing scenario.

cc @seriousben

@jrschumacher
Copy link
Contributor Author

Here is a proof: 97c6445

@jrschumacher
Copy link
Contributor Author

@bajtos can we discuss the use of beforeEach vs before and finding some alternative like this?

@seriousben
Copy link

We might need both of them, as a beforeEach and as a Before so that we can easily build scenario based tests.

But another solution would be to provide helper instead that can be used within a before or beforeEach.

A bit like what is used in loopback/test/user.test.js

@jrschumacher
Copy link
Contributor Author

@seriousben from your branch I created this: #42

Can you look over and give me some feedback.

@bajtos
Copy link
Contributor

bajtos commented Jan 27, 2015

+1 for creating a helper method that can be used on its own.

@jrschumacher
Copy link
Contributor Author

@bajtos can you describe what your idea of a separate helper would be? I'd be happy to implement it, but need some direction one what everyone is thinking.

Also what if we create a chai plugin similar to chia-http or chia-change which sounds like what we are trying to do in some sense.

@bajtos
Copy link
Contributor

bajtos commented Jan 27, 2015

can you describe what your idea of a separate helper would be?

Here is an usage example:

beforeEach(helpers.cleanDatabase);
// or perhaps
before(given.emptyDatabase);

Nice to have:

beforeEach(given.noModelInstancesOf('User'));

Also what if we create a chai plugin similar to chia-http or chia-change which sounds like what we are trying to do in some sense.

I don't have a strong opinion on that.

@jrschumacher
Copy link
Contributor Author

@bajtos I'm going to work on building the helpers this this week. We obviously want to be backwards compatible, but using the helpers seems like its going to require a lot of refactoring... and I really need to get whenCalledRemotely to stop running beforeEach ASAP its really making writing tests difficult.

If I go with the helper routine how would I handle withApp and such being that they will need to be the same as whenCalledRemotely due to the priority of before executing before beforeEach?

@jrschumacher
Copy link
Contributor Author

@bajtos I know you aren't a fan of #43 which is fine. Would #42 satisfy or is it too complex?

@jrschumacher
Copy link
Contributor Author

@bajtos ping

@bajtos
Copy link
Contributor

bajtos commented Mar 9, 2015

I don't want to block progress here, I guess #42 is the best we can achieve using the current suboptimal API, so no objections from me.

@jrschumacher
Copy link
Contributor Author

@bajtos Thank you.

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

No branches or pull requests

3 participants