Skip to content

Commit

Permalink
Merge pull request #57 from raghuhit/master
Browse files Browse the repository at this point in the history
Adding test for local stop function
  • Loading branch information
raghuhit authored Aug 24, 2018
2 parents 671433c + c515454 commit 425d73a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/Local.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,17 @@ function Local(){
var killChecker = setInterval(() => {
if(childPids.length === 0) {
clearInterval(killChecker);
process.kill(this.pid);

// This gives time to local binary to send kill signal to railsApp.
setTimeout(() => {
try {
process.kill(this.pid);
// This gives time to local binary to send kill signal to railsApp.
setTimeout(() => {
this.isProcessRunning = false;
callback();
}, 2000);
} catch(err) {
this.isProcessRunning = false;
callback();
}, 2000);
}
}
for(var i in childPids) {
try {
Expand All @@ -274,7 +278,7 @@ function Local(){
childPids.splice(i, 1);
}
}
},100);
},500);
});
};
}
Expand Down
11 changes: 11 additions & 0 deletions test/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ describe('Local', function () {
});
});

it('should stop local', function (done) {
this.timeout(MAX_TIMEOUT);
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY}, function(){
expect(bsLocal.isRunning()).to.equal(true);
bsLocal.stop(function(){
expect(bsLocal.isRunning()).to.equal(false);
done();
});
});
});

afterEach(function (done) {
this.timeout(60000);
bsLocal.stop(done);
Expand Down

0 comments on commit 425d73a

Please sign in to comment.