test-runner
test-runner copied to clipboard
[Bug] Missing dependency requirement
Describe the bug
$ npx run test-storybook
● Test suite failed to run
Cannot find module '@babel/preset-typescript'
Require stack:
- /project/node_modules/@babel/core/lib/config/files/plugins.js
- /project/node_modules/@babel/core/lib/config/files/index.js
- /project/node_modules/@babel/core/lib/index.js
- /project/node_modules/@storybook/test-runner/playwright/transform.js
- /project/node_modules/jest-util/build/requireOrImportModule.js
- /project/node_modules/jest-util/build/index.js
- /project/node_modules/jest-resolve/build/resolver.js
- /project/node_modules/jest-resolve/build/index.js
- /project/node_modules/jest-runtime/build/index.js
- /project/node_modules/jest-runner/build/testWorker.js
- /project/node_modules/jest-worker/build/workers/processChild.js
It seems that @babel/core
and babel presets referenced from playwright/transform.js
should be added to dependencies
or peerDependencies
in your package.json
.
This is not a problem for most people because babel dependencies will be available at the root of node_modules/
anyway but it becomes a problem when the package manager (yarn
in my case) decides to move babel packages to where they are used instead of the top-level:
-
/project/node_modules/@storybook/core-common/node_modules/@babel/preset-typescript
-
/project/node_modules/jscodeshift/node_modules/@babel/preset-typescript
Workaround
As a workaround, users facing this issue can declare these dependencies in their own package.json
:
{
"devDependencies": {
"@babel/core": "^7.18.9",
"@babel/preset-env": "^7.18.9",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6"
}
}
Environment
- OS: Fedora 36
- Node.js version: 16.15.0
- NPM version: 8.5.5
- Yarn version: 1.22.18
Also being bitten by this, using yarn. Took me ages to figure out where the issue originated and finding this issue. Seems like a definite bug.
Also experiencing this issue using yarn :/ Yarn version: 1.22.19 Node version 14.20.0
Adding @babel/preset-typescript
as a devDependency did the trick. Thanks for the workaround!
Running into the same issue. Is it possible to make it at least not bundle the React dependency, as I'm running this in a Vue project?
Running into the same issue. Is it possible to make it at least not bundle the React dependency, as I'm running this in a Vue project?
+1
The same issue. Workaround in this topic helped