Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

notanengineercom
Copy link
Collaborator

@notanengineercom notanengineercom commented Mar 9, 2024

Showcases a draft on how to improve the readability and developer experience when evaluating assertions (received didNotReceive).
Originated from the suggestion in #140, with this addition, we'd be recording stack traces of where a call was made. I also tried to enrich the assertion failure description with information like what has been called, how and what's expected:

Screenshot 2024-03-10 at 00 43 41

Closes #140
Closes #27
Closes #138

@notanengineercom notanengineercom self-assigned this Mar 9, 2024
@notanengineercom
Copy link
Collaborator Author

Tests for node.js 12, 14 and 16 fail just because the formatting of stack traces lines are slightly different than in the newer node.js versions (>= 18).

@ffMathy
Copy link
Owner

ffMathy commented Mar 10, 2024

Wow, this is an amazing addition! I am currently sick and have been for a week, but hope to contribute at a faster pace soon ❤️

@ffMathy
Copy link
Owner

ffMathy commented Mar 10, 2024

Yeah let's just drop support for those older versions of node BTW.

18 and up should be fine.

@notanengineercom
Copy link
Collaborator Author

Thanks 😄
Alright, what do you think about following node.js' release schedule? That would mean (looking at April'24), we'd run the CI tests against versions 18, 20 and 22.
Get well soon 🫶🏼

@ffMathy
Copy link
Owner

ffMathy commented Mar 10, 2024

Thanks 😄 Alright, what do you think about following node.js' release schedule? That would mean (looking at April'24), we'd run the CI tests against versions 18, 20 and 22. Get well soon 🫶🏼

I love that strategy! Let's do that ❤️

Thank you!

@notanengineercom notanengineercom marked this pull request as ready for review March 20, 2024 21:28
@notanengineercom
Copy link
Collaborator Author

I made some changes to allow a bunch of serialization options:

  • using console.log
  • using JSON.stringify
  • getting a primitive from substitute

It just generates a string with a simple tree of the substitution object (not exposing any internals)

@notanengineercom notanengineercom merged commit 30c69d9 into master Mar 21, 2024
@notanengineercom notanengineercom deleted the improved-assertion-messages branch March 21, 2024 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide stack traces with "All calls received to method..." JSON.stringify() does not play well Unable to use mocks with angular TestBed
2 participants