question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module 'contentlayer/client' by running test with Jest

See original GitHub issue

I 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:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
ThisIsMissEmcommented, Oct 27, 2022

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.

0reactions
stale[bot]commented, Dec 26, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found