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

This commit is contained in:
Joel Einbinder 2020-08-16 14:41:33 -07:00 committed by GitHub
parent f983432536
commit d516f81eeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -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();

View File

@ -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);