Update config files to prevent duplicated JavaScript tests#2638
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2638 +/- ##
=======================================
Coverage 51.88% 51.88%
=======================================
Files 127 127
Lines 5476 5476
Branches 1202 1202
=======================================
Hits 2841 2841
Misses 2340 2340
Partials 295 295 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Currently waiting for #2637 to be merged first before finalizing this PR. Finalized PR will remove the need for hardcoding |
|
Thanks for your effort on this PR! @AgentHagu . This would definitely help immensely with the DevOps process. One suggestion! - We could also consider excluding the test files from our build pipeline, if it is determined that we don't need the js files at all to run the tests. This can complement the test config, so there are two layers of checks to ensure we don''t run duplicated test files. E.g.: I referenced from stackoverflow When we add more tests in the future, it can help reduce workload on |
Thanks @gerteck for the catch! I've looked into this suggestion and excluding the To resolve this, I've added new |
Since the TypeScript test files are fully adapted and the tests are passing, we can remove the commented code from the jest.config.js file. The remaining JavaScript test will be addressed by the PR MarkBind#2637.
1748119 to
f95edb2
Compare
Tim-Siu
left a comment
There was a problem hiding this comment.
This Pull Request addresses the problems of duplicated JS/TS tests while also enhancing compilation efficiency.
- It configures Jest to only test TypeScript files.
- It configures
tsconfigso that TypeScript test files are not compiled during the build. - The changes in step 2 break linting. This PR creates separate configuration files for linting, adhering to the practices mentioned in this StackOverflow post.
The PR indeed cuts down the test cases run from 462 (commit ea7cf57) to 231 (commit 87616eb). LGTM!
lhw-1
left a comment
There was a problem hiding this comment.
Thanks for the PR @AgentHagu! This should've been done after the bulk of the TypeScript migration was completed - so at least we've tied up a loose end.
|
@lhw-1 Each PR must have a SEMVER impact label, please remember to label the PR properly. |
What is the purpose of this pull request?
Overview of changes:
Fixes #2629
As explained in #2629, the core package tests are currently running twice due to having TypeScript and JavaScript versions. To prevent running these tests twice, we can update
jest.config.jsto only run files that match*.test.ts, thereby ignoring the JavaScript tests.This PR also updates the
tsconfig.jsonfiles to further prevent thetest.tsfiles from being compiled to JavaScript in the first place, which also reduces unnecessary output files and keeps the codebase cleaner.Anything you'd like to highlight/discuss:
As discussed with @gerteck, there shouldn't be a scenario where the TypeScript test passes but the JavaScript version of that test fails -- unless there is an issue during the conversion, which isn't within our scope.
Excluding the
test.tsfiles had an unintended side-effect on ESLint as it previously usedtsconfig.jsonas reference to find TypeScript files to lint. To fix this issue, the PR also adds newtsconfig.lint.jsonfiles as the new reference files for.eslintrc.js.Testing instructions:
cd packages/corenpm run testProposed commit message: (wrap lines at 72 characters)
Update config files to prevent duplicated JavaScript tests
The core package tests are currently being run twice because both
TypeScript and JavaScript versions of the test files exist. This leads to
unnecessary duplication of testing, increasing the number of tests
being executed each test run.
To fix this, we update
jest.config.jsto only run the TypeScript testfiles (
**/*.test.ts), ignoring the Javascript versions of the tests.We also update the
tsconfig.jsonfiles to prevent compilation ofthe
test.tsfiles into JavaScript in the first place. This has the addedbenefit of reducing the number of unnecessary output files.
A side-effect of excluding the
test.tsfiles intsconfig.jsonwas thatthe ESLint could no longer recognize or find those files for linting. To
fix this, we add
tsconfig.lint.jsonfiles as the new reference files for.eslintrc.jsChecklist: ☑️
Reviewer checklist:
Indicate the SEMVER impact of the PR:
At the end of the review, please label the PR with the appropriate label:
r.Major,r.Minor,r.Patch.Breaking change release note preparation (if applicable):