FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: update test-require-json.js by alejandronanez · Pull Request #28358 · nodejs/node · GitHub

/ node Public

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

Closed
alejandronanez wants to merge 2 commits into
nodejs:masterfrom
alejandronanez:test__require-json
Closed

test: update test-require-json.js#28358
alejandronanez wants to merge 2 commits into
nodejs:masterfrom
alejandronanez:test__require-json

Conversation

Copy link
Copy Markdown
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 added the test Issues and PRs related to the tests. label Jun 21, 2019

Trott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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!

Copy link
Copy Markdown
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 commented Jun 22, 2019

Copy link
Copy Markdown
Member

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().

Copy link
Copy Markdown
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 added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Jun 22, 2019

Trott commented Jun 24, 2019

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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

Let me know what you think, thanks!

Comment thread test/parallel/test-require-json.js Outdated
Comment thread test/parallel/test-require-json.js Outdated

Trott commented Jun 28, 2019

Copy link
Copy Markdown
Member

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

Let me know what you think, thanks!

We're getting close!

Trott added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Jul 3, 2019

Copy link
Copy Markdown
Collaborator

Comment thread test/parallel/test-require-json.js Outdated
Trott removed the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Jul 3, 2019

BridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM with the comment addressed.

Copy link
Copy Markdown
Contributor Author

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

Trott commented Jul 15, 2019

Copy link
Copy Markdown
Member

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 force-pushed the test__require-json branch from edac779 to 0ab7845 Compare July 30, 2019 23:50

Trott commented Jul 30, 2019

Copy link
Copy Markdown
Member

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!

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
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 commented Jul 31, 2019

Copy link
Copy Markdown
Member

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 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

8 participants


Back | FazBrowse Home | New Git URL