-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
hangs at end of tests #41
Comments
I don't have a lot of details, so I'm sorry if I ask obvious questions, but are you closing your Express server at the end of the tests? |
no. Is there something to pipe in as jasmine automatically handles the starting of the express server so I would have expected it to stop on it's own. |
Neither jasmine nor gulp-jasmine knows express, so your express server is either started in your specs or by one of the module you load. Once again, I don't have a lot of details on your use case, but if I were to guess, you probably have something like this: server.spec.js: var server = require("../server"); server.js: var express = require("express");
var app = express();
app.listen(9000); Is that the case? |
yes, that is the pretty similar to what we have. I wonder how jasmine-node does it then within grunt which is what we had before. Sorry for not providing enough information. |
I haven't worked with grunt that much, so I can't help you on that, but I think the current jasmine behavior is correct. Setup and teardown are the responsibility of the tests, not the framework. I'll close this issue, but feel free to discuss it further if you think this is a required feature. If you want a quick fix, you can listen to the end of the stream in your gulp file with: As an aside, a pattern that I found useful for building and testing express servers is setting the server up in a module and starting it in another. Something like that: server.js var express = require("express");
function Server () {
this._app = express();
this._app.get("/", function (req, res) {
res.send("Hello world!");
})
}
Server.prototype.start = function (port, otherOptions) {
this._instance = this._app.listen(port);
};
Server.prototype.stop = function (cb) {
this._instance.close(cb);
};
module.exports = new Server(); start.js var server = require("./server");
server.start(process.env.port, "other options"); This way, when you import server.js in your specs, you can start and stop it manually in your tests, either in beforeAll/endAll or beforeEach/endEach depending on the atomicity of your tests. Hope this helps. |
When running against a set of nodejs tests they pass but it never exists.
Output which then requires a ctrl-c
Any idea?
The text was updated successfully, but these errors were encountered: