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

adding test-specific tsconfig files in appropriate dirs #1996

Merged
merged 3 commits into from
Jan 4, 2024

Conversation

ATorrise
Copy link
Contributor

@ATorrise ATorrise commented Jan 2, 2024

What It Does
Configures typescript test files to include jest type information, reducing the amount of distracting, not-real-yet-still-highlighted-as-such errors when working in test files

How to Test
Pull branch and start opening up some test files, making sure there are no errors like:

Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.ts(2582) 

Review Checklist
I certify that I have:

Copy link

codecov bot commented Jan 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6f30932) 91.03% compared to head (17a076d) 91.03%.
Report is 2 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #1996   +/-   ##
=======================================
  Coverage   91.03%   91.03%           
=======================================
  Files         635      635           
  Lines       18610    18610           
  Branches     3859     3859           
=======================================
  Hits        16941    16941           
  Misses       1668     1668           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

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

TL;DR: LGTM! 😋


I like this solution a lot.
It resolved the problem of having to import @types/jest in a random file for those Jest functions (describe, afterAll, ...) to be recognized as actual functions.

I'm curious if we could do some technique to reduce duplication. Something like...

"extends": "../../tsconfig.json",

One thing to keep in mind that this only fixes tests that are under the packages/PKG/__tests__/ directory. For example, this won't help with
packages/imperative/src/utilities/__tests__/CliUtils.unit.test.ts since the tsconfig.json is under packages/imperative/__tests__/ 😋

Signed-off-by: Amber Torrise <[email protected]>
@zFernand0
Copy link
Member

One thing to keep in mind that this only fixes tests that are under the packages/PKG/tests/ directory. For example, this won't help with
packages/imperative/src/utilities/tests/CliUtils.unit.test.ts since the tsconfig.json is under packages/imperative/tests/ 😋

I take that back.
Even files from within the imperative/src/utilities/__tests__/ work now 😋

Copy link

sonarcloud bot commented Jan 3, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @ATorrise!

@ATorrise ATorrise merged commit 1667924 into next Jan 4, 2024
44 checks passed
@ATorrise ATorrise deleted the tsconfig_secondAttempt branch January 4, 2024 16:38
Copy link

github-actions bot commented Jan 4, 2024

Release succeeded for the next branch. 🎉

The following packages have been published:

Powered by Octorelease 🚀

@ATorrise ATorrise mentioned this pull request Jan 31, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

4 participants