canirequire

canirequireCommonJS › @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.

Latest
0.2.2 (Oct 2, 2023)
Module format
CommonJS
Last CommonJS version
0.2.2
TypeScript types
Bundled
Node engines
not declared
License
MIT

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.

Runtimerequire("@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).

VersionsFormatFirst published
0.0.0 – 0.2.2CommonJSOct 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

Similar popularity