diff --git a/packages/expect/src/__tests__/asymmetricMatchers.test.ts b/packages/expect/src/__tests__/asymmetricMatchers.test.ts index 66dfcc40add1..dae2bd6eeba1 100644 --- a/packages/expect/src/__tests__/asymmetricMatchers.test.ts +++ b/packages/expect/src/__tests__/asymmetricMatchers.test.ts @@ -227,7 +227,6 @@ test('ObjectContaining matches defined properties', () => { test('ObjectContaining matches prototype properties', () => { const prototypeObject = {foo: 'bar'}; let obj; - if (Object.create) { obj = Object.create(prototypeObject); } else { @@ -248,7 +247,7 @@ test('ObjectContaining throws for non-objects', () => { test('ObjectContaining does not match when non-objects are passed to the expect function as arguments', () => { for (const test of [ - objectContaining({}).asymmetricMatch("jest"), + objectContaining({}).asymmetricMatch('jest'), objectContaining({}).asymmetricMatch(10), objectContaining({}).asymmetricMatch(false), objectContaining({}).asymmetricMatch(undefined), @@ -256,8 +255,7 @@ test('ObjectContaining does not match when non-objects are passed to the expect ]) { jestExpect(test).toEqual(false); } - -}) +}); test('ObjectContaining does not mutate the sample', () => { const sample = {foo: {bar: {}}}; diff --git a/packages/expect/src/asymmetricMatchers.ts b/packages/expect/src/asymmetricMatchers.ts index cf1c53ec3928..a128863e0983 100644 --- a/packages/expect/src/asymmetricMatchers.ts +++ b/packages/expect/src/asymmetricMatchers.ts @@ -227,7 +227,6 @@ class ObjectContaining extends AsymmetricMatcher< } asymmetricMatch(other: any) { - // Ensures that the argument passed to the objectContaining method is an object if (typeof this.sample !== 'object') { throw new TypeError( @@ -243,7 +242,7 @@ class ObjectContaining extends AsymmetricMatcher< if (typeof other !== 'object' || Array.isArray(other)) { return false; } - + let result = true; const matcherContext = this.getMatcherContext();