Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update test-require-json.js #28358

Closed

Conversation

alejandronanez
Copy link
Contributor

Used assert.throws instead of assert.ok in test/parallel/test-require-json.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Jun 21, 2019
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome @alejandronanez and thanks for the pull request. I imagine the idea here was to replace the try/catch. This change as it stands merely complicates the test. If you're at Code & Learn and you're not sure how to proceed, ask a mentor for some help! Thanks!

@alejandronanez
Copy link
Contributor Author

Hey @Trott thanks for chiming in!

Actually this change was made based on the feedback from @ErickWendel at the Code & Learn session, fwiw, this was the suggested solution for this change:

The test contains a try / catch which does not verify that the error is actually triggered. Please refactor this by using the correct assert function instead.

How should I proceed from here then?

Thanks again :)!

@Trott
Copy link
Member

Trott commented Jun 22, 2019

Actually this change was made based on the feedback from @ErickWendel at the Code & Learn session, fwiw, this was the suggested solution for this change:

The test contains a try / catch which does not verify that the error is actually triggered. Please refactor this by using the correct assert function instead.

How should I proceed from here then?

Replace the entire try/catch block with an equivalent assert.throws() call. It is not a case of replacing assert.ok() with assert.throws().

@ErickWendel
Copy link
Member

haha @alejandronanez sorry, I told you to put the assert.throws but I forgot to tell you to remove the entire try/catch. It was busy with many questions during the session. If you wanna some help, feel free to reach me :D

@BridgeAR BridgeAR added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Jun 22, 2019
@Trott
Copy link
Member

Trott commented Jun 24, 2019

As this change currently stands, it does not merely complicate the test. It also invalidates it! The test will always pass. The error is no longer checked, other than to confirm that throw err throws err. It's easy to see how the change can be improved on and be totally acceptable, but right now, it complicates the code and invalidates the test.

@alejandronanez
Copy link
Contributor Author

Hello @Trott, I made some updates to the test.

Let me know what you think, thanks!

@Trott
Copy link
Member

Trott commented Jun 28, 2019

Hello @Trott, I made some updates to the test.

Let me know what you think, thanks!

We're getting close!

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 3, 2019
@nodejs-github-bot
Copy link
Collaborator

@Trott Trott removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 3, 2019
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the comment addressed.

@alejandronanez
Copy link
Contributor Author

wow I completely missed this conversation! I already fixed the lint errors in edac77982b56b5a358361048ad6166e7f2f1c725. Thanks y'all for your feedback

@Trott
Copy link
Member

Trott commented Jul 15, 2019

This change means that we are no longer checking that the path that failed is included in the error message. Is that OK? @BridgeAR @addaleax @trivikr @jasnell

@Trott
Copy link
Member

Trott commented Jul 30, 2019

Rebased against master, added the regexp back so we're still checking that the message correctly reports the path of the file that caused the problem, and force-pushed.

@jasnell @trivikr @addaleax @BridgeAR PTAL to confirm that this is still to your liking. Thanks!

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Trott pushed a commit to Trott/io.js that referenced this pull request Jul 31, 2019
Use assert.throws() instead of try/catch.

PR-URL: nodejs#28358
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@Trott
Copy link
Member

Trott commented Jul 31, 2019

Landed in c3b2111.

Thanks for the contribution! 🎉

(If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.)

@Trott Trott closed this Jul 31, 2019
targos pushed a commit that referenced this pull request Aug 2, 2019
Use assert.throws() instead of try/catch.

PR-URL: #28358
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants