-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Setup test suite for type definitions #8794
Comments
We chatted in discord: I feel like tsd is a good spot for this and there are techniques like |
Working with @MLH-Fellowship on this, summarising some of the internal fact-finding here.
SolutionRequirements:
Ideal solution:
|
This seems huge for making sure that public APIs do not change across versions and that expectations of how Typescript resolves the types remains true. I am able to use the expectType functions (those work without any Jest changes) but the expectError and similar just will not. I also have to mock up the implementation because, unlike when it's run under "tsd", running the tests under Jest DOES mean that the code will be executed and that means that it must, at least, not throw an error. |
This landed in #10407. While we don't test that much yet, the infrastructure is now in place 🎉 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Jest is written in TypeScript, but that doesn't mean that the different APIs Jest injects into a test are particularly well typed. Having good type tests for
expect
and the different methods available on thejest
object (jest.spyOn
,jest.mock
etc) would be great to assert that they provide the DX they should. Especially since we hope to include global typings with Jest 25, we should ensure we are safe to move quickly if they are painful for people coming from the DefinitelyTyped types. Especially assertions that invalid things are reported as type errors would be great.Current test suite in DT: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jest/jest-tests.ts
I'm not sure what tool would be best for this, but something like https://github.com/microsoft/dtslint or https://github.com/SamVerschueren/tsd maybe? It should run as part of Jest's test suite, so we need a custom runner for them (or some other tool that does the same job).
This runner could then of course be used by other people who want to test their type defs, and run those tests with Jest.
/cc @orta if you have any thoughts you wanna share on this
The text was updated successfully, but these errors were encountered: