chore: allow empty string in regex patterns (#31804)

This commit is contained in:
Pavel Feldman 2024-07-22 13:02:12 -07:00 committed by GitHub
parent d87cb7a303
commit cf1a313a0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View File

@ -19,8 +19,6 @@ import type { Metadata } from '../../types/test';
import type * as reporterTypes from '../../types/testReporter';
import type { ReporterV2 } from '../reporters/reporterV2';
// -- Reuse boundary -- Everything below this line is reused in the vscode extension.
export type StringIntern = (s: string) => string;
export type JsonLocation = reporterTypes.Location;
export type JsonError = string;
@ -613,7 +611,7 @@ export function serializeRegexPatterns(patterns: string | RegExp | (string | Reg
export function parseRegexPatterns(patterns: JsonPattern[]): (string | RegExp)[] {
return patterns.map(p => {
if (p.s)
if (p.s !== undefined)
return p.s;
return new RegExp(p.r!.source, p.r!.flags);
});

View File

@ -38,6 +38,7 @@ export class TestServerConnection implements TestServerInterface, TestServerInte
private _ws: WebSocket;
private _callbacks = new Map<number, { resolve: (arg: any) => void, reject: (arg: Error) => void }>();
private _connectedPromise: Promise<void>;
private _isClosed = false;
constructor(wsURL: string) {
this.onClose = this._onCloseEmitter.event;
@ -70,11 +71,16 @@ export class TestServerConnection implements TestServerInterface, TestServerInte
this._ws.addEventListener('error', r);
});
this._ws.addEventListener('close', () => {
this._isClosed = true;
this._onCloseEmitter.fire();
clearInterval(pingInterval);
});
}
isClosed(): boolean {
return this._isClosed;
}
private async _sendMessage(method: string, params?: any): Promise<any> {
const logForTest = (globalThis as any).__logForTest;
logForTest?.({ method, params });

View File

@ -21,8 +21,6 @@ import type * as teleReceiver from '../isomorphic/teleReceiver';
import { serializeRegexPatterns } from '../isomorphic/teleReceiver';
import type { ReporterV2 } from './reporterV2';
// -- Reuse boundary -- Everything below this line is reused in the vscode extension.
export type TeleReporterEmitterOptions = {
omitOutput?: boolean;
omitBuffers?: boolean;