[test] Move callback args to right side of assertion #24366
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Generally,
expect(*)
should always receive the "bare" object i.e. not include any property access. The reason being that in case of a mismatch you want to see actionable debug information from the matcher. Otherwise you almost always end up logging the actual value anyway once it fails. The exception to this rule is if you don't have useful matchers to use.expect(sinonSpy.calledWith(value)).to.equal(true)
is problematic for two reasons:Specifically,
DateTimePicker.test
allows to select full date end-to-end
was failing after internal refactoring (#24367). It didn't provide actionable information that revealed that the behavior was still correct, but the testing approach problematic. I used this opportunity to refactor the other usages of.calledWith
.I don't see how we can safely flag these uses statically
no-restricted-properties
has no information about the context so it might flag appropriate uses. I think the "no access on the left side of the assertion" is a better heuristic.