New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jest-runner-tsd

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-runner-tsd

A Jest runner that tests typescript typings using tsd under the hood

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
832
decreased by-87.69%
Maintainers
1
Weekly downloads
 
Created
Source

jest-runner-tsd

A Jest runner that tests typescript typings using tsd under the hood.

Install

Install jest-runner-tsd

yarn add --dev jest-runner-tsd

# or with NPM

npm install --save-dev jest-runner-tsd

Adding to Jest Config

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"
}
...

Run

To start the test, just execute the following command

yarn test-types

Writing tests

This runner uses TSD. To see the available assertions, checkout it's documentation

For JavaScript Projects

There are multiple ways you can pass a type definition file.

Default

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.json

You 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"
}
Docblocks

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
 **/

For TypeScript Projects

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

Package last updated on 17 Aug 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc