Cannot find module 'contentlayer/client' by running test with Jest
See original GitHub issueI found this error when run jest for testing
Cannot find module 'contentlayer/client' from '.contentlayer/generated/index.mjs'
Require stack:
.contentlayer/generated/index.mjs
pages/index.tsx
__tests__/index.test.tsx
here is the codesandbox that fork next-contentlayer-example and setup Jest. you could run testing by yarn test
codesandbox: https://codesandbox.io/p/github/hawkup/next-contentlayer-example/draft/serene-wozniak
repository: https://github.com/hawkup/next-contentlayer-example/tree/draft/serene-wozniak
I already added this config on jest.config.js
{
moduleNameMapper: {
"contentlayer/generated": "<rootDir>/.contentlayer/generated"
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
Diff - 7888dedb89..1062ad0828 - chromium/src - Git at Google
Run (data_[normalized_id].get(), + /*has_retryable_error=*/false); return; } - std::move(callback). ... +<script type="module" src="index.js"></script>
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Just to clarify, my PR was against Next 12, not Next 13 — I’d guess their new build tool has a different way to indicate what to and what not to compile.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.