Skip to content

Commit

Permalink
Use optional chaining in toHaveLength matcher (#9826)
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorBreakfast committed Apr 16, 2020
1 parent cab4c1d commit 2a92e7f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/expect/src/matchers.ts
Expand Up @@ -628,10 +628,7 @@ const matchers: MatchersObject = {
promise: this.promise,
};

if (
typeof received !== 'string' &&
(!received || typeof received.length !== 'number')
) {
if (typeof received?.length !== 'number') {
throw new Error(
matcherErrorMessage(
matcherHint(matcherName, undefined, undefined, options),
Expand Down

0 comments on commit 2a92e7f

Please sign in to comment.