![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
jest-runner-tsd
Advanced tools
jest-runner-tsd
A Jest runner that tests typescript typings using tsd under the hood.
Install jest-runner-tsd
yarn add --dev jest-runner-tsd
# or with NPM
npm install --save-dev jest-runner-tsd
Create a jest.config.types.js
file and have the runner property set to jest-runner-tsd
as shown below:
module.exports = {
runner: 'jest-runner-tsd',
};
In the project package.json
file, modify the scripts block to use the configuration file as show below:
...
"scripts": {
...
"type-tests": "yarn jest --config jest.config.types.js"
}
...
To start the test, just execute the following command
yarn test-types
This runner uses TSD. To see the available assertions, checkout it's documentation
There are multiple ways you can pass a type definition file.
The type definitions should be in a file named index.d.ts
in the root directory of the project by default.
types
property in package.jsonYou can also set your types
property in package.json. The runner will automatically pick the type defintion file from there.
{
...
"types": "path/to/types.d.ts"
}
If the type definition file is located somewhere else then specify its path in the top of respective test file using the @type
inside a docblock.
/**
* @type ../../custom/path/to/types.d.ts
**/
Note: This is only a workaround. A stable solution may be introduced in future.
Due to limitations in TSD, the only solution now for testing types in TypeScript projects would be to have a empty type definition file and specify it's path using one of the many methods explained above.
FAQs
Run your TypeScript type tests using Jest
We found that jest-runner-tsd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.