Repository navigation
feat(compiler): Add fixedOrder option to expectDiagnostics - #7453
Harlan Enciso (harlanenciso112) wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
we use something else than changeset for this repo called chronus. Either follow the comment that should get added soon or use pnpm chronus add
|
❌ There is undocummented changes. Run The following packages have changes but are not documented.
Show changes |
| expectation.code, | ||
| `Diagnostic at index ${i} has non matching code.\n${message}`, | ||
|
|
||
| if (fixedOrder) { |
There was a problem hiding this comment.
The approach we decided here was to sort the diagnostics so they diff can still be used.
The reason I didn't want to add this at it was was exactly because it made the test experience worse when it didn't find the match and in general it was bad pattern to have multiple diagnostics tested at the same time. We decided that sorting the diagnositcs and expectation would still provide the benefits while not loosing the diff
Timothee Guerin (timotheeguerin)
left a comment
There was a problem hiding this comment.
Thanks for the contribution, I think unfortunately we'd prefer to go with a bit of a different approach for this.
Have you found yourself needing this feature?
|
Thanks for your feedback Timothee Guerin (@timotheeguerin)! I understand your preference for sorting the diagnostics instead of the I implemented this feature based on the issue description which suggested adding a Regarding the changeset, I tried to create one manually but wasn't familiar with Chronus. I'll try using Would you like me to:
Thanks for the guidance! |
|
You can keep modifying this PR, and yeah sorry about the issue description we have not been doing a good job of relecting our internal discussions on them For chronus you can also just use that comment which has a link to add it #7453 (comment) |
|
Hi @Harlan Enciso (@harlanenciso112). The PR will be closed since the PR has no update for 60 days. If this is still relevant please reopen. |
Resolves #5818
Description
Added a new
fixedOrderoption to theexpectDiagnosticsfunction that allows testing diagnostics regardless of the order they appear in. This makes tests more resilient to code changes that might alter diagnostic order without changing the actual diagnostic content.Problem
Tests that use
expectDiagnosticswould fail when diagnostic order changes, even though this should not be considered a breaking change. Library test authors had to create wrappers to pre-sort diagnostics collections.Solution
ExpectDiagnosticsOptionsinterface withfixedOrderboolean optionfixedOrderoption toexpectDiagnostics(defaults totruefor backward compatibility)fixedOrder: false, diagnostics can match in any order using a new matching algorithmImplementation Details
validateDiagnosticsInOrder(): Preserves original ordered matching behaviorvalidateDiagnosticsAnyOrder(): New unordered matching with clear error messagesdiagnosticMatches(): Extracted matching logic for reusabilityExpectDiagnosticsOptions: Type-safe options interfaceUsage Examples