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
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-runner-tsd - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

13

package.json
{
"name": "jest-runner-tsd",
"version": "5.0.0",
"version": "6.0.0",
"description": "Run your TypeScript type tests using Jest",

@@ -37,3 +37,3 @@ "keywords": [

"create-jest-runner": "^0.12.0",
"tsd-lite": "^0.7.0"
"tsd-lite": "^0.8.0"
},

@@ -46,3 +46,3 @@ "devDependencies": {

"@tsconfig/node14": "^1.0.3",
"@tsd/typescript": "~4.9.0",
"@tsd/typescript": "~5.1.0",
"@types/babel__code-frame": "^7.0.3",

@@ -58,3 +58,3 @@ "@typescript-eslint/eslint-plugin": "^5.0.0",

"prettier": "^2.4.1",
"typescript": "~4.9.0"
"typescript": "~5.1.0"
},

@@ -68,3 +68,6 @@ "peerDependencies": {

},
"packageManager": "yarn@3.4.1"
"packageManager": "yarn@3.6.0",
"engines": {
"node": ">=16"
}
}

@@ -14,3 +14,4 @@ # `jest-runner-tsd`

- `jest.config` is used to discover test files;
- and `tsconfig.json` provides configuration for TS compiler. For details see [Configuration](#configuration) section.
- `tsconfig.json` provides configuration for TS compiler. For details see [Configuration](#configuration) section;
- the type assertions must be imported from `tsd-lite` package.

@@ -54,3 +55,3 @@ ## Install

**Hint:** run `yarn tsc -p path/to/__typetests__ --showConfig` to print the configuration which applies to the test files.
**Tip:** run `yarn tsc -p path/to/__typetests__ --showConfig` to print the configuration which applies to the test files.

@@ -80,18 +81,49 @@ **Note:** if `tsconfig.json` is not found, the compiler will fall back to the default configuration.

## Writing Tests
Let's say you defined a `JsonObject` type:
```ts
// JsonObject.ts
type JsonValue = string | number | boolean | JsonObject | Array<JsonValue>;
export interface JsonObject {
[key: string]: JsonValue;
}
```
It is relatively complex, so it is worth adding a type test to prevent mistakes and regression in the future:
```ts
// __typetests__/JsonObject.test.ts
import { expectAssignable, expectNotAssignable } from 'tsd-lite';
import type { JsonObject } from '../JsonObject.js';
expectAssignable<JsonObject>({
caption: 'test',
count: 100,
isTest: true,
location: { name: 'test', start: [1, 2], valid: false, x: 10, y: 20 },
values: [0, 10, 20, { x: 1, y: 2 }, true, 'test', ['a', 'b']],
});
expectNotAssignable<JsonObject>({
filter: () => {},
});
```
**Tip:** For the full list of type testing assertions see the [documentation of `tsd-lite`](https://github.com/mrazauskas/tsd-lite#assertions).
## Running Tests
If all is set, simply run `yarn jest -c jest.config.tsd.js` command. Or better include a script in `package.json`:
If all is set, simply run `yarn jest --config jest.config.tsd.js` command. Or better include a script in `package.json`:
```json
"scripts": {
"test:types": "jest -c jest.config.tsd.js"
"test:types": "jest --config jest.config.tsd.js"
}
```
## Learn More
To learn more about `tsd` and its assertions see the [documentation](https://github.com/SamVerschueren/tsd).
## License
[MIT](https://github.com/jest-community/jest-runner-tsd/blob/main/LICENSE.md) © Jest Community
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