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

commented Jun 21, 2019

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
@Trott
Copy link
Member

left a comment

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

This comment has been minimized.

Copy link
Contributor Author

commented Jun 22, 2019

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor

commented Jun 22, 2019

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

@Trott

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor Author

commented Jun 27, 2019

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

Let me know what you think, thanks!

@Trott

This comment has been minimized.

Copy link
Member

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 approved these changes Jul 3, 2019

@Trott Trott added the author ready label Jul 3, 2019

@nodejs-github-bot

This comment has been minimized.

@trivikr
trivikr approved these changes Jul 3, 2019

@Trott Trott removed the author ready label Jul 3, 2019

@BridgeAR
Copy link
Member

left a comment

LGTM with the comment addressed.

@alejandronanez alejandronanez force-pushed the alejandronanez:test__require-json branch from 438cebe to edac779 Jul 15, 2019

@alejandronanez

This comment has been minimized.

Copy link
Contributor Author

commented Jul 15, 2019

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

@Trott

This comment has been minimized.

Copy link
Member

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

alejandronanez and others added 2 commits Jun 21, 2019
test: use assert.throws() in test-require-json.js
Use assert.throws() instead of try/catch.

@Trott Trott force-pushed the alejandronanez:test__require-json branch from edac779 to 0ab7845 Jul 30, 2019

@Trott

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

Trott added a commit to Trott/io.js that referenced this pull request Jul 31, 2019
test: use assert.throws() in test-require-json.js
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

This comment has been minimized.

Copy link
Member

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 added a commit that referenced this pull request Aug 2, 2019
test: use assert.throws() in test-require-json.js
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>
@BridgeAR BridgeAR referenced this pull request Aug 6, 2019
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
test: use assert.throws() in test-require-json.js
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>
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
test: use assert.throws() in test-require-json.js
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.