You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running jest at project that doesn't use styled-components. Following warnings are emitted.
(node:2000) UnhandledPromiseRejectionWarning: Error: Cannot find module 'styled-components' from 'node_modules/jest-preview/dist/styled-components.js'
Require stack:
node_modules/jest-preview/dist/styled-components.js
node_modules/jest-preview/dist/index.js
src/__tests__/App.test.tsx
However, Jest was able to find:
'./styled-components.d.ts''./styled-components.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['tsx', 'ts', 'web.js', 'js', 'web.ts', 'web.tsx', 'json', 'web.jsx', 'jsx', 'node'].
See https://jestjs.io/docs/configuration#modulefileextensions-arraystring
at Resolver.resolveModule (/vitejs-vite-hlfd63/node_modules/jest-resolve/build/resolver.js:324:11)
at Resolver._getVirtualMockPath (/vitejs-vite-hlfd63/node_modules/jest-resolve/build/resolver.js:471:14)
at Resolver._getAbsolutePath (/vitejs-vite-hlfd63/node_modules/jest-resolve/build/resolver.js:457:14)
at Resolver.getModuleID (/vitejs-vite-hlfd63/node_modules/jest-resolve/build/resolver.js:424:31)
at Runtime._shouldMock (/vitejs-vite-hlfd63/node_modules/jest-runtime/build/index.js:1917:37)
at Runtime.requireModuleOrMock (/vitejs-vite-hlfd63/node_modules/jest-runtime/build/index.js:1204:14)
at Module.Object.<anonymous> (/vitejs-vite-hlfd63/node_modules/jest-preview/dist/styled-components.js:1:203)
at Runtime._execModule (/vitejs-vite-hlfd63/node_modules/jest-runtime/build/index.js:1646:24)
at Runtime._loadModule (/vitejs-vite-hlfd63/node_modules/jest-runtime/build/index.js:1185:12)
at Runtime.requireModule (/vitejs-vite-hlfd63/node_modules/jest-runtime/build/index.js:1009:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2000) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async functionwithout a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:2000) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Reason is maybe jest-preview try-catch the require('styled-components') wrong way.
When running
jest
at project that doesn't usestyled-components
. Following warnings are emitted.Reason is maybe
jest-preview
try-catch therequire('styled-components')
wrong way.jest-preview/src/preview.ts
Lines 11 to 24 in 44f0d64
The text was updated successfully, but these errors were encountered: