chore: follow up to target close message

This commit is contained in:
Pavel Feldman 2023-10-12 14:58:19 -07:00
parent 9d76c09ddb
commit f8a30fb726
2 changed files with 4 additions and 3 deletions

View File

@ -184,7 +184,7 @@ export class Connection extends EventEmitter {
}
close(cause?: Error) {
this._closedError = cause || new TargetClosedError();
this._closedError = new TargetClosedError();
if (cause)
rewriteErrorMessage(this._closedError, this._closedError.message + '\nCaused by: ' + cause.toString());
for (const callback of this._callbacks.values())

View File

@ -16,6 +16,7 @@
import ws from 'ws';
import { androidTest as test, expect } from './androidTest';
import { kTargetClosedErrorMessage } from '../config/errors';
// Force a separate worker to avoid messing up with `androidDevice` fixture.
test.use({ launchOptions: {} });
@ -95,7 +96,7 @@ test('android.launchServer BrowserServer.close() will disconnect the device', as
try {
const device = await playwright._android.connect(browserServer.wsEndpoint());
await browserServer.close();
await expect(device.shell('echo 123')).rejects.toThrow('androidDevice.shell: Browser has been closed');
await expect(device.shell('echo 123')).rejects.toThrow('androidDevice.shell: ' + kTargetClosedErrorMessage);
} finally {
await browserServer.close();
}
@ -106,7 +107,7 @@ test('android.launchServer BrowserServer.kill() will disconnect the device', as
try {
const device = await playwright._android.connect(browserServer.wsEndpoint());
await browserServer.kill();
await expect(device.shell('echo 123')).rejects.toThrow('androidDevice.shell: Browser has been closed');
await expect(device.shell('echo 123')).rejects.toThrow('androidDevice.shell: ' + kTargetClosedErrorMessage);
} finally {
await browserServer.close();
}