-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Proposal: add a contextValue
to TestMessage
#190277
Comments
- Implements the proposal in #190277 by adding a `contextValue` to TestMessages added to test runs. - Make the `FloatingClickMenu` reusable outside the editor, and uses it to implement a `testing/message/content` contribution point. With this extensions can do things like: 
- Implements the proposal in #190277 by adding a `contextValue` to TestMessages added to test runs. - Make the `FloatingClickMenu` reusable outside the editor, and uses it to implement a `testing/message/content` contribution point. With this extensions can do things like: 
@connor4312, a bit of late feedback regarding the snapshots: our use case will fall into the "re-run test" category. It would be unlikely for us to update snapshots directly based on the test output for the following reasons:
For us, updating snapshots is really just a test run with a special flag. Therefore, it seems natural for the action to sit with the rest of the run/debug menu items. The TestMessage contextMenu will not add any additional benefit to our use case. Just to clarify, we don't object to this feature, especially when it helps other extensions and use cases. This is just some context for reference. |
Sounds good. However, on "Jest already knows how to update snapshots; we should not replicate the same logic" -- you could use this action to trigger Jest's snapshot update, you don't necessarily need to do the update by hand. |
Motivation
There are sometimes actions users may want to take on test results. For example, as @ulugbekna references #189680 (comment), applying the "actual" value to test expectations is a common case. We do it using diagnostics and the proposed
testObserver
API in the selfhost test provider, but this is not a great experience. @orta's Jest extension adds a context menu to rerun the test and apply the snapshot.Proposal
Simply enough, to add a
contextValue
on the TestMessage class (along with some extramenus
where actions can be show)Limitations & Alternatives
The main limitation arises if the information on the TestMessage and TestItem is insufficient to accomplish the necessary tasks. For snapshot testing, it should be sufficient to apply the
actualOutput
, but if it's not, then the runner is stuck re-running the test.A fix for this would be if we ensure that the TestMessage instance passed to the executed command is the same as the one initially created in the test result, allow the consumer to use a
WeakMap
approach. However, this requires retaining test messages in the extension host, which we don't currently do and may be burdensome.An alternative would be to allow the
TestMessage
to have a list ofCommand
s. This is more flexible, namely in that custom arguments can be supplied to the command, but we'd have to re-invent how to determine where actions are shown in the UI.The text was updated successfully, but these errors were encountered: