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

Added event handler to process the stream end signal #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/index.es6
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ module.exports.test = function(options) {
tempDir: options.reportDir
});
runTestsPromise.done(result => {
serverProcess.on('close', () => {
setTimeout(function(){
Copy link
Contributor Author

@jmhomedes-ob jmhomedes-ob Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback() is called inside a timeout because I detected that when it's called with an error it interrupts de generation of HTML gemini report. It's working this way, but I'm sure the code is improveable and reviews/suggestions accepted.

Now you can update documentation by naming that with this change users will be able to do:

gulp
.src('src', { read: false })
.pipe(visTest.test({
    ...
}))
.on('end', function(){
    // will execute allways
})
.on('error', function(error){
    // will execute only when error signal (some test has failed)
});

var error = null;
if(result.failed){
error = 'Error: ' + result.failed + ' tests failed';
}
callback(error);
}, 2000);
});
serverProcess.kill('SIGTERM');
spawn('open', [`${options.reportDir}/index.html`]).on('error', function() {});
});
Expand Down Expand Up @@ -270,6 +279,11 @@ module.exports.gather = function(options) {
reporters: ['flat'],
})
.done(result => {
serverProcess.on('close', () => {
setTimeout(function(){
callback();
}, 2000);
});
serverProcess.kill('SIGTERM');
});
}
Expand Down