Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(rpc): add a custom toJSON to help jest's expect library (#3489)

Joel Einbinderd516f81eeb6e
diff --git a/src/rpc/client/channelOwner.ts b/src/rpc/client/channelOwner.ts
index 0ea022574d..d0c2bcbb6d 100644
--- a/src/rpc/client/channelOwner.ts
+++ b/src/rpc/client/channelOwner.ts
@@ -106,6 +106,17 @@ export abstract class ChannelOwner<T extends Channel = Channel, Initializer = {}
throw e;
}
}
+
+ private toJSON() {
+ // Jest's expect library tries to print objects sometimes.
+ // RPC objects can contain links to lots of other objects,
+ // which can cause jest to crash. Let's help it out
+ // by just returning the important values.
+ return {
+ _type: this._type,
+ _guid: this._guid,
+ };
+ }
}
const debugLogger = new DebugLoggerSink();
diff --git a/utils/doclint/check_public_api/JSBuilder.js b/utils/doclint/check_public_api/JSBuilder.js
index 98e5abd5c7..b287e1233f 100644
--- a/utils/doclint/check_public_api/JSBuilder.js
+++ b/utils/doclint/check_public_api/JSBuilder.js
@@ -234,6 +234,8 @@ function checkSources(sources) {
continue;
if (name.startsWith('_'))
continue;
+ if (member.valueDeclaration && ts.getCombinedModifierFlags(member.valueDeclaration) & ts.ModifierFlags.Private)
+ continue;
if (EventEmitter.prototype.hasOwnProperty(name))
continue;
const memberType = checker.getTypeOfSymbolAtLocation(member, member.valueDeclaration);