canirequire › CommonJS › @storybook/testing-library
Is @storybook/testing-library ESM-only? Can you require() it?
Instrumented version of Testing Library for Storybook Interactions
Last verified Sep 9, 2026 against @storybook/testing-library@0.2.2. JSON
CommonJS CommonJS — require() works on every Node.js version
@storybook/testing-library ships CommonJS only. require("@storybook/testing-library") works everywhere. import "@storybook/testing-library" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.
It also declares a "module" field, so bundlers such as webpack, Vite and esbuild pick up an ESM build for tree-shaking.
Deprecated: In Storybook 8, this package functionality has been integrated to a new package called @storybook/test, which uses Vitest APIs for an improved experience. When upgrading to Storybook 8 with 'npx storybook@latest upgrade', you will get prompted and will get an automigration for the new package. Please migrate when you can.
Does @storybook/testing-library@0.2.2 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("@storybook/testing-library") from a CommonJS file and import "@storybook/testing-library" from an ES module.
| Runtime | require("@storybook/testing-library") | import "@storybook/testing-library" |
|---|---|---|
| Node.js 18 | ✓ works | ✓ works |
| Node.js 20 | ✓ works | ✓ works |
| Node.js 22 | ✓ works | ✓ works |
| Node.js 24 | ✓ works | ✓ works |
| Node.js 26 | ✓ works | ✓ works |
| Bun 1.4 | ✓ works | ✓ works |
How to import @storybook/testing-library
ES modules (import)
import testingLibrary from "@storybook/testing-library";Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.
CommonJS (require)
const testingLibrary = require("@storybook/testing-library");Module format by version
Derived from the type, main and exports fields of every stable release on npm (18 versions; the newest 18 shown).
| Versions | Format | First published |
|---|---|---|
| 0.0.0 – 0.2.2 | CommonJS | Oct 15, 2021 |
Frequently asked
Is @storybook/testing-library ESM-only?
@storybook/testing-library@0.2.2 is a CommonJS package. @storybook/testing-library ships CommonJS only. require("@storybook/testing-library") works everywhere. import "@storybook/testing-library" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.
Can I import @storybook/testing-library with ES module syntax?
Yes. import testingLibrary from "@storybook/testing-library" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.
Does @storybook/testing-library work in Bun?
Yes. import "@storybook/testing-library" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does @storybook/testing-library ship TypeScript types?
Yes. @storybook/testing-library bundles its own type declarations; no @types package is needed.
Links
Other commonjs packages
- debug 4.4.3CommonJS
- semver 7.8.5CommonJS
- ms 2.1.3CommonJS
- picomatch 4.0.7CommonJS
- ajv 8.20.0CommonJS
- source-map 0.8.0CommonJS
- react-is 19.2.8CommonJS
- readable-stream 4.7.0CommonJS
Similar popularity
- @rollup/plugin-image 3.0.3Dual
- @ethersproject/solidity 5.8.0CommonJS
- @semantic-release/changelog 7.0.0ESM-only
- @material-ui/core 4.12.4CommonJS
- @babel/node 8.0.1CommonJS
- @material-ui/icons 4.11.3CommonJS
- @ethersproject/contracts 5.8.0CommonJS
- @oclif/command 1.8.36CommonJS