Skip to content

Commit

Permalink
fix(rpc): add a custom toJSON to help jest's expect library (#3489)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelEinbinder authored Aug 16, 2020
1 parent f983432 commit d516f81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/rpc/client/channelOwner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions utils/doclint/check_public_api/JSBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d516f81

Please sign in to comment.