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

testing code with setInterval doesn't return #829

Closed
csulok opened this issue Dec 16, 2014 · 3 comments
Closed

testing code with setInterval doesn't return #829

csulok opened this issue Dec 16, 2014 · 3 comments

Comments

@csulok
Copy link

csulok commented Dec 16, 2014

I recently ran into an issue with testing an intergration of passport-saml using gulp-jasmine, where the issue was passport-saml created a long running interval as part of its cache, which kept it from returning This is needed for gulp watch to function at all, and simple gulp tasks to properly quit and return to the terminal.

Please see the discussion here: node-saml/passport-saml#68

Is there a best practice or strategy that would allow easily handling these situations?

My current workaround involved finding the culprit with console.log(process._getActiveHandles()); and console.log(process._getActiveRequests()); a few seconds after the finish event of a gulp pipe, then finding the code that creates the timer with grep, and then figuring out how to cancel the interval if possible. I'd like to avoid this ever ever ever again.

The test was nothing fancy:

gulp.task("test", function () {

    return gulp.src(["src/**/*.js", "test/*.spec.js"])

        //test files
        .pipe(jasmine({
            includeStackTrace: true,
            verbose: true
        }))

        .on("error", function(error) {
            console.log(error.toString());
            this.emit("end");
        });

});

and the jasmine test is also quite simple:

it("tests login pass", function(done) {
    request.post({
        url: "http://localhost:" + p + "/login/saml",
        followRedirect: false
    }, function(err, response/*, body*/) {
        expect(response.statusCode).toBe(302);
        done();
    });
});
@yocontra
Copy link
Member

IMO I wouldn't use gulp-jasmine. I have yet to see a test runner that works well within gulps paradigms. I would just have gulp shell out to a command (npm test) or call the jasmine module or whatever directly. Since this is a jasmine specific issue I'm going to close this, you'll have better luck opening this on gulp-jasmine or passport-saml since that seems to be where the issue actually is.

@csulok
Copy link
Author

csulok commented Dec 16, 2014

The projects where I used gulp had build and continuous testing tasks that were very very similar, so having 2 systems for them would be less than ideal. gulp-watch is needed for continuous testing, so I hope gulp 4.0 will make things smoother here.

@yocontra
Copy link
Member

@csulok It's really an issue with jasmine. There are some tools that were built poorly and don't work well with other tools - most testing frameworks we're done this way.

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

2 participants