Comments (5)
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?
from gulp-jasmine.
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.
from gulp-jasmine.
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?
from gulp-jasmine.
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.
from gulp-jasmine.
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: .on('end', function() {
and force close node.
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.
from gulp-jasmine.
Related Issues (20)
- Unable to give references of file needed in specs from gulpfile.js
- Issue DEPRECATION : Setting randomizeTests directly is deprecated, please use the random option in `configure`
- Update Jasmine to 3.4 HOT 2
- Upgrade to jasmine 4 HOT 3
- issues with require caching HOT 4
- export jasmine object HOT 9
- Replace silent reporter with onComplete callback
- Error trying to use config in Node 6
- Broken with Jasmine 2.5.0? HOT 9
- Config option for custom Jasmine-instance HOT 4
- gulp-jasmine runs the tests twice when Jasmine version is 2.5.2 HOT 3
- Tests that should fail pass using gulp-jasmine HOT 1
- jasmine doesn't seem to run HOT 1
- Jasmine never getting called if over 16 files loaded HOT 2
- jasmineDone event not called when tests fail
- process exits with exit code 0 when tests fail HOT 3
- Cannot load module using require.
- deleteRequireCache blows the stack for circlular referenced files HOT 3
- MaxListenersExceededWarning: Possible EventEmitter memory leak detected. HOT 1
- Running a focused test throws an error when it shouldn't. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-jasmine.