jest-extended icon indicating copy to clipboard operation
jest-extended copied to clipboard

Handle `.not` cases in toThrowWithMessage

Open natealcedo opened this issue 7 years ago β€’ 6 comments

What

During the initial implementation of toThrowWithMessage I forgot to handle the .not during validation. As such, when a user uses .not, validation doesn't work at all.

Why

The matcher won't correctly validate .not cases.

Notes

Housekeeping

  • [x] Unit tests
  • [x] Documentation is up to date
  • [x] No additional lint warnings
  • [x] Add yourself to contributors list (yarn contributor)
  • [x] Typescript definitions are added/updated where relevant

natealcedo avatar Oct 21 '18 04:10 natealcedo

Codecov Report

Merging #173 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #173   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         109    109           
  Lines         554    555    +1     
  Branches       97     98    +1     
=====================================
+ Hits          554    555    +1
Impacted Files Coverage Ξ”
src/matchers/toThrowWithMessage/index.js 100% <100%> (ΓΈ) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update c9cc718...fef3e82. Read the comment docs.

codecov-io avatar Oct 21 '18 04:10 codecov-io

Hey @mattphillips, can we get this merged in? My current implementation only handled the happy case. :)

natealcedo avatar Jan 30 '19 06:01 natealcedo

Sorry about the huge delay... Could you rebase this? πŸ™‚

SimenB avatar Oct 11 '21 07:10 SimenB

I merged in some of main, but I'm not 100% how to resolve the conflict. Sorry!

SimenB avatar Oct 11 '21 08:10 SimenB

I'll take a look at this next week no sweat :)

natealcedo avatar Oct 17 '21 02:10 natealcedo

I added this test and it seemed to pass. Is this still an issue.

test('my test', () => {
  expect(() => {
    throw new TypeError('Expected message');
  }).not.toThrowWithMessage.call(
    { utils: { matcherHint: matcherHint, printExpected: printExpected, printReceived: printReceived } },
    SyntaxError,
    'Expected message',
  );
});

keeganwitt avatar Mar 15 '23 03:03 keeganwitt