fix: close chrome when closing electron (#19322)

This commit is contained in:
Alejandro Estrada
2021-12-09 16:12:47 -05:00
committed by GitHub
parent 65cf6e899d
commit f79bdd665a
3 changed files with 5 additions and 7 deletions

View File

@@ -520,13 +520,13 @@ export = {
const originalBrowserKill = launchedBrowser.kill
/* @ts-expect-error */
launchedBrowser.kill = async (...args) => {
launchedBrowser.kill = (...args) => {
debug('closing remote interface client')
await criClient.close()
criClient.close()
debug('closing chrome')
await originalBrowserKill.apply(launchedBrowser, args)
originalBrowserKill.apply(launchedBrowser, args)
}
await this._maybeRecordVideo(criClient, options, browser.majorVersion)

View File

@@ -191,7 +191,6 @@ export const create = Bluebird.method((target: websocketUrl, onAsynchronousError
maybeDebugCdpMessages(cri)
cri.send = Bluebird.promisify(cri.send, { context: cri })
cri.close = Bluebird.promisify(cri.close, { context: cri })
// @see https://github.com/cyrus-and/chrome-remote-interface/issues/72
cri._notifier.on('disconnect', reconnect)

View File

@@ -300,10 +300,9 @@ describe('lib/browsers/chrome', () => {
.then(() => {
expect(this.launchedBrowser.kill).to.be.a('function')
return this.launchedBrowser.kill()
}).then(() => {
expect(this.criClient.close).to.be.calledOnce
this.launchedBrowser.kill()
expect(this.criClient.close).to.be.calledOnce
expect(kill).to.be.calledOnce
})
})