Socket
Socket
Sign inDemoInstall

@storybook/jest

Package Overview
Dependencies
Maintainers
31
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/jest - npm Package Compare versions

Comparing version 0.2.2--canary.42.ce81fe8.0 to 0.2.2--canary.43.6016551883.0

1

dist/index.d.ts
/// <reference types="jest" />
/// <reference types="@testing-library/jest-dom" />
import * as mock from 'jest-mock';

@@ -3,0 +4,0 @@

14

package.json
{
"name": "@storybook/jest",
"version": "0.2.2--canary.42.ce81fe8.0",
"version": "0.2.2--canary.43.6016551883.0",
"description": "Instrumented version of Jest for Storybook Interactions",

@@ -17,2 +17,10 @@ "repository": {

],
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"scripts": {

@@ -25,3 +33,3 @@ "build": "tsup",

"@storybook/expect": "storybook-jest",
"@testing-library/jest-dom": "^6.1.0",
"@testing-library/jest-dom": "^6.1.2",
"@types/jest": "28.1.3",

@@ -33,3 +41,3 @@ "jest-mock": "^27.3.0"

"@auto-it/released": "^10.37.6",
"@storybook/instrumenter": "next",
"@storybook/instrumenter": "^7.0.0",
"@storybook/linter-config": "^3.1.2",

@@ -36,0 +44,0 @@ "@types/react": "*",

@@ -5,44 +5,2 @@ # Storybook Jest

## FAQ
### Typescript does not recognize expect().toBeInTheDocument()
This is likely an issue with newer package managers.
The `@storybook/jest` package provides some type augmentations so that `expect` has extended matchers coming from Testing Library. The way it works, is that `@storybook/jest` depends on `@testing-library/jest-dom`, a package that depends on `@types/testing-library__jest-dom`. That @types package should be hoisted in your project in order for your types to fully work. As a result, you should have a `node_modules/@types/testing-library__jest-dom` directory. If you don't, then the types won't exist and that's why you're having issues.
For instance, if you have a yarn project, hoisting happens automatically. However if you're using **pnpm**, `@types` are not hoisted automatically, you will have to add a `.npmrc` file with the following setting:
```js
// .npmrc
public-hoist-pattern[]=@types*
```
Otherwise, installing `@types/testing-library__jest-dom` as a direct dependency should have the same effect and fix your issue.
If you are still experiencing issues after making these changes, it's very likely that your `tsconfig.json` file contains specific type overrides, which means that it will ignore automatic types, for instance:
```json
{
"compilerOptions": {
"types": [
"node",
"mocha",
]
}
}
```
In that case, make sure to add `testing-library__jest-dom` to the `types` array:
```json
{
"compilerOptions": {
"types": [
"node",
"mocha",
"testing-library__jest-dom"
]
}
}
```
[jest-dom](https://github.com/testing-library/jest-dom) matchers are automatically included as well.
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