simplereach / ember-cli-betamax

MIT License
14 stars 4 forks source link

"feature" request: restart server for each test #5

Open jamesarosen opened 9 years ago

jamesarosen commented 9 years ago

Currently, this library starts the server before the suite run and stops it after.

That leads to the situation where server.responses and server.requests have shared state from test to test. That, in turn, makes it harder to make assertions about requests and responses and makes it easy to accidentally have one test step on another by defining a fake response.

What do you think of changing the above lines to the following?

QUnit.testStart(startServer);
QUnit.testDone(stopServer);
jamesarosen commented 9 years ago

Or would that mess with the library's ability to record?

andremalan commented 9 years ago

@jamesarosen the biggest reason that it doesn't do that right now is that it allows the recorder to memoize recordings from other steps. So for instance if your app requests /users for every test, having it not restart means that we can then only make one request to the server while recording. It also means that you have better guarantees, if the request changes during recording, a newer result won't clobber an old one.

jamesarosen commented 9 years ago

I've long since forgotten my original reason for writing this. I wonder if I meant to do the stop and restart only in playback mode.