Testem gulp task hangs after finished

一笑奈何 提交于 2019-12-08 13:46:39

问题


This gulp task doesn't exit after finished, I have to manually press Ctrl-C to exit.

gulp.task('test', function(done) {
    var testem = require('testem');

    var testemOptions = {
        file: 'testem.json'
    };

    var t = new testem();

    t.startCI(testemOptions, done);
});

How can i make this task exit properly?

Note: Actually it exits itself, but it takes like 15 seconds after finished.

Output:

[15:49:59] Using gulpfile ~/gulpfile.js
[15:49:59] Starting 'test'...
ok 1 PhantomJS 1.9 - Integration Tests: Home Index Page

1..3
# tests 3
# pass  3
# fail  0

# ok
[15:50:00] Finished 'test' after 1.33 s

回答1:


Managed to reproduce your problem using the Chromium launcher, but it's should be the same with PhantomJS. There is indeed a 15sec CPU delay between the end of the task and the actual exit of the process.

> time gulp testem
Starting 'testem'...
ok 1 Chrome 32.0 - sass: link
ok 2 Chrome 32.0 - Unit - HomeRoute: exists
ok 3 Chrome 32.0 - Unit - HomeRoute: #model
ok 4 Chrome 32.0 - Unit - HomeRoute: redirect

1..4
# tests 4
# pass  4
# fail  0

# ok
Finished 'testem' after 938 ms
gulp testem  1.27s user 0.25s system 9% cpu 16.581 total

By removing the done callback you set on the task and passing to startCI that don't take this as parameter,

var testem = require('testem');

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

  var testemOptions = {
    file: 'testem.json'
  };

  var t = new testem();
  return t.startCI(testemOptions);

});

the task run as expected and exit properly on finish :

> time gulp testem
Starting 'testem'...
ok 1 Chrome 32.0 - sass: link
ok 2 Chrome 32.0 - Unit - HomeRoute: exists
ok 3 Chrome 32.0 - Unit - HomeRoute: #model
ok 4 Chrome 32.0 - Unit - HomeRoute: redirect

1..4
# tests 4
# pass  4
# fail  0

# ok
gulp testem  1.26s user 0.19s system 91% cpu 1.582 total

By the way, don't know you can do this, simply pass an object with a file property to startCI, I thought you should read the config file using fs.readFile and parsing its data into JSON to launch testem using the config parameters you provided inside testem.json.

One more thing, there is a gulp plugin, gulp-testem that I did not have the opportunity to try, but which may be helpful.



来源:https://stackoverflow.com/questions/25019955/testem-gulp-task-hangs-after-finished

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!