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: adjust createSourceFileAndTypeChecker to verify passed code has valid syntax #703

Merged

Conversation

ronami
Copy link
Collaborator

@ronami ronami commented Feb 4, 2025

PR Checklist

Overview

This is a small follow-up to #698 (comment), and it adjusts the test helper createSourceFileAndTypeChecker to check that passed syntax is valid (to prevent accidental invalid syntax on test cases).

I've checked locally that this would fail before the change on the linked comment.


Codecov fails on this, but I don't think there's much to do (it's a test helper, should it even be included in the codecov report?).

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 11.11111% with 8 lines in your changes missing coverage. Please review.

Project coverage is 77.08%. Comparing base (0bd7d7a) to head (7dfa740).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/test/utils.ts 11.11% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #703      +/-   ##
==========================================
- Coverage   77.20%   77.08%   -0.12%     
==========================================
  Files          50       50              
  Lines        5000     5009       +9     
  Branches      687      688       +1     
==========================================
+ Hits         3860     3861       +1     
- Misses       1139     1147       +8     
  Partials        1        1              
Flag Coverage Δ
4.8.4 74.44% <11.11%> (-0.12%) ⬇️
latest 76.66% <11.11%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

if (diagnostics.length > 0) {
throw new Error(
ts.flattenDiagnosticMessageText(
diagnostics[0].messageText,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Showing a single error each time seems easier to handle.

@ronami ronami marked this pull request as ready for review February 4, 2025 12:37
@RebeccaStevens RebeccaStevens changed the title chore(tests): adjust createSourceFileAndTypeChecker to verify passed code has valid syntax test: adjust createSourceFileAndTypeChecker to verify passed code has valid syntax Feb 4, 2025
Copy link
Owner

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

:shipit:!

And yeah I don't mind the coverage gap here, seems reasonable to ignore test files. I think in general it's good to check that test ifs inline in tests aren't unnecessary - sometimes folks use them to get around type checking. But for this, not so useful IMO.

@JoshuaKGoldberg JoshuaKGoldberg merged commit 00184ae into JoshuaKGoldberg:main Feb 5, 2025
22 of 26 checks passed
@JoshuaKGoldberg
Copy link
Owner

@all-contributors please add @ronami for test.

🤖 Beep boop! This comment was added automatically by all-contributors-auto-action.
Not all contributions can be detected from Git & GitHub alone. Please comment any missing contribution types this bot missed.
...and of course, thank you for contributing! 💙

Copy link
Contributor

@JoshuaKGoldberg

I've put up a pull request to add @ronami! 🎉

JoshuaKGoldberg pushed a commit that referenced this pull request Feb 5, 2025
Adds @ronami as a contributor for test.

This was requested by JoshuaKGoldberg [in this
comment](#703 (comment))

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
@ronami ronami deleted the check-test-case-syntax branch February 5, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants