diff --git a/packages/expect/src/jest-expect.ts b/packages/expect/src/jest-expect.ts index 920813d83..22fc3b17a 100644 --- a/packages/expect/src/jest-expect.ts +++ b/packages/expect/src/jest-expect.ts @@ -608,14 +608,13 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => { const pass = spy.mock.calls.some(callArg => equalsArgumentArray(callArg, args)) const isNot = utils.flag(this, 'negate') as boolean - const msg = utils.getMessage(this, [ - pass, - `expected "${spyName}" to be called with arguments: #{exp}`, - `expected "${spyName}" to not be called with arguments: #{exp}`, - args, - ]) - if ((pass && isNot) || (!pass && !isNot)) { + const msg = utils.getMessage(this, [ + pass, + `expected "${spyName}" to be called with arguments: #{exp}`, + `expected "${spyName}" to not be called with arguments: #{exp}`, + args, + ]) throw new AssertionError(formatCalls(spy, msg, args)) } }) @@ -627,14 +626,13 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => { const pass = hasCallWithArgs && callCount === 1 const isNot = utils.flag(this, 'negate') as boolean - const msg = utils.getMessage(this, [ - pass, - `expected "${spyName}" to be called once with arguments: #{exp}`, - `expected "${spyName}" to not be called once with arguments: #{exp}`, - args, - ]) - if ((pass && isNot) || (!pass && !isNot)) { + const msg = utils.getMessage(this, [ + pass, + `expected "${spyName}" to be called once with arguments: #{exp}`, + `expected "${spyName}" to not be called once with arguments: #{exp}`, + args, + ]) throw new AssertionError(formatCalls(spy, msg, args)) } })