create-typescript-app icon indicating copy to clipboard operation
create-typescript-app copied to clipboard

🧪 Testing: Fill in test coverage for augmentOptionsWithExcludes

Open JoshuaKGoldberg opened this issue 1 year ago • 3 comments

Bug Report Checklist

  • [X] I have tried restarting my IDE and the issue persists.
  • [X] I have pulled the latest main branch of the repository.
  • [X] I have searched for related issues and found none that matched my issue.

Overview

#695 added a bunch of code changes. I didn't fully unit test them - not because I was too impatient to write tests (me?! never!!), but because I wanted to leave some good first issues as followups. Definitely that.

augmentOptionsWithExcludes is missing unit test coverage for ~several dozen lines~ one or two lines. augmentOptionsWithExcludes.test.ts only tests the case of fully automated usage. It doesn't test what happens when the user is prompted for anything. Let's add tests to augmentOptionsWithExcludes.test.ts that exercise the calls to prompt!

Additional Info

You'll likely need to use Vitest mocking - specifically, vi.mock. Search for vi.mock("@clack/prompts" in code to see how other unit tests accomplish this.

We don't need complete 100% unit test coverage of the file. If the tests are giving you grief, feel free to send an incomplete Draft PR with comments asking for help. ❤️


Note that the code might have been refactored since this issue was filed. Names might be slightly off. The general spirit of this issue should still be valid though.

JoshuaKGoldberg avatar Aug 25 '23 13:08 JoshuaKGoldberg

hey, I would love to contribute, can you please help me. I"m a beginner here...Thanks

shobhit9957 avatar Aug 25 '23 13:08 shobhit9957

👋 hey @shobhit9957, great! My advice would be to:

  1. Read through all the docs in this repo -they're linked to in its README.md-
  2. Read through the 'getting started' guide of the tools needed to contribute: TypeScript, pnpm, Vitest
  3. See how other tests are written in this repo
  4. Try adding a test yourself
  5. Send a draft PR once you've made some progress - and ask any questions you need in that draft PR

Cheers!

I'm planning on writing a more helpful blog post soon. Hopefully that list is useful until then.

JoshuaKGoldberg avatar Aug 25 '23 13:08 JoshuaKGoldberg

hey 😊thanks @JoshuaKGoldberg will follow the steps you've provided and update you with the feedbacks!,

shobhit9957 avatar Aug 25 '23 13:08 shobhit9957

Ah, this was previously done. Nice.

JoshuaKGoldberg avatar Aug 15 '24 02:08 JoshuaKGoldberg