Open tay1orjones opened 6 months ago
@tay1orjones It is really nice to see TSTyche in the list. I am its author. Long story short, I was writing and contributing type tests to Jest repo for some time. At the moment there are more than 1000 assertions. Working at this scale was a pain with the available tooling. That is why I wrote TSTyche.
For instance, at large scale there was a need to have describe()
and test()
helpers with .skip
and .only
. That’s a must for deducing an issue or building new feature. Also we wanted to test on different versions of TypeScript easily. TSTyche can do all this and much more. All Jest’s type test now are ran by TSTyche.
Differently from all other type testing tools, TSTyche is wrapping around TypeScript’s language service. It allows per file queries instead of working with the whole TS program. And more. For example, another feature I am thinking about is an API which makes possible testing in memory generate files, i.e. passing arbitrary text to the compiler and asking for diagnostics (and/or processing type test assertions).
If this sounds like the automation solution you are looking for, I am more than interested to collaborate. The implementation on TSTyche side is rather trivial. The fs
host object must be passed to the language service factory. Obviously, that can be a virtual fs
which is generating test files on demand.
To be honest, I never had a chance to work with component type tests. And that sounds even more interesting ;D
Earlier today TSTyche 2.1 shipped with new .toAcceptProps()
matcher that is designed to test well.. prop types of JSX components! Thanks for inspiration.
@mrazauskas Thanks for popping in here! The features you listed are definitely intriguing and something we'll consider when we take up this work. toAcceptProps
in particular could be really valuable.
Thank you for submitting a feature request. Your proposal is open and will soon be triaged by the Carbon team.
If your proposal is accepted and the Carbon team has bandwidth they will take on the issue, or else request you or other volunteers from the community to work on this issue.
Background
Once https://github.com/carbon-design-system/carbon/issues/12513 is fully complete, it would be beneficial if we had a way to be more confident in future changes to the component types. Specifically to ensure that types provided through
@carbon/react
follow the established Semantic Versioning guidelines for the package.Potential approach
For component proptypes we have a very helpful setup where the proptypes for all components are collected and snapshotted into a single file, PublicAPI-test.js.snap. As changes to proptypes are made, the snapshot requires being updated, which shows up in the PR diff. This makes it really clear what's changing and makes it much easier to spot potential issues. We could attempt to mirror this setup in some way to provide more explicit visibility on every PR when a potentially semver-incompatible change is made to component types. The prominent solution for this would be to use https://api-extractor.com/
Conversely, rather than snapshotting these, some other options to research include:
Additional concerns
Related resources