-
-
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
Implement tests for type definitions in Jest #10407
Conversation
This reverts commit 73fd3c5.
We only emit the TS types for the // jest.config.types.js
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
module.exports = {
displayName: 'typings test',
runner: 'jest-runner-tsd',
testMatch: ['<rootDir>/test-types/*.test.ts'],
}; then add a script for running it {
"scripts": {
"test-types": "yarn jest --config jest.config.types.js"
}
} and finally in the workflow after this: https://github.com/facebook/jest/blob/c9c8dba4dd8de34269bdb971173659399bcbfd55/.github/workflows/nodejs.yml#L40-L41 |
jest.config.js
Outdated
'<rootDir>', | ||
'<rootDir>/examples/*/', | ||
{ | ||
displayName: 'typings test', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do something like this to make it be more "typescript color" than green?
displayName: 'typings test', | |
displayName: { | |
color: 'blue', | |
name: 'types', | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Related to #8794
This PR adds type definitions tests for Jest's own API. The types are imported from
@jest/types
and@jest/globals
. The tests forfoo
are defined in a file callfoo.test.ts
present in thetest-types
directory under the root directory.A custom runner called
jest-runner-tsd
is being used for the type definition tests.Under the hood, a forked version of tsd is being used for carrying out the tests.
This PR implements the type testing feature. More type tests for other Jest APIs will be added as a separate PR.
Demo
The above screenshot demonstrate the working of both the failing as well as passing type tests for a few API of the
top-level-jest-namespace
. The failing tests are just for demo purpose and will be deleted once the PR is approved.Authors