Skip to content

Commit 425d73a

Browse files
authored
Merge pull request #57 from raghuhit/master
Adding test for local stop function
2 parents 671433c + c515454 commit 425d73a

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

lib/Local.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,17 @@ function Local(){
259259
var killChecker = setInterval(() => {
260260
if(childPids.length === 0) {
261261
clearInterval(killChecker);
262-
process.kill(this.pid);
263-
264-
// This gives time to local binary to send kill signal to railsApp.
265-
setTimeout(() => {
262+
try {
263+
process.kill(this.pid);
264+
// This gives time to local binary to send kill signal to railsApp.
265+
setTimeout(() => {
266+
this.isProcessRunning = false;
267+
callback();
268+
}, 2000);
269+
} catch(err) {
266270
this.isProcessRunning = false;
267271
callback();
268-
}, 2000);
272+
}
269273
}
270274
for(var i in childPids) {
271275
try {
@@ -274,7 +278,7 @@ function Local(){
274278
childPids.splice(i, 1);
275279
}
276280
}
277-
},100);
281+
},500);
278282
});
279283
};
280284
}

test/local.js

+11
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ describe('Local', function () {
210210
});
211211
});
212212

213+
it('should stop local', function (done) {
214+
this.timeout(MAX_TIMEOUT);
215+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY}, function(){
216+
expect(bsLocal.isRunning()).to.equal(true);
217+
bsLocal.stop(function(){
218+
expect(bsLocal.isRunning()).to.equal(false);
219+
done();
220+
});
221+
});
222+
});
223+
213224
afterEach(function (done) {
214225
this.timeout(60000);
215226
bsLocal.stop(done);

0 commit comments

Comments
 (0)