[docs] Upgrade note with Jest version requirements and workaround for older versions of Jest (#5619)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
This commit is contained in:
Aaron Stone 2025-04-28 05:19:55 -07:00 committed by GitHub
parent cfc33f7741
commit aca743b499
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# Frequently Asked Questions
This FAQ has bits of advice and workarounds for common problems.
## I'm using Jest and get import errors when I run my test suite
Test suite failures of the form:
``` text
Cannot find module @opentelemetry/foo/bar from @opentelemetry/...
```
but package `@opentelemetry/foo` is installed may occur with Jest < v29.4.
This is because older versions of `jest-resolve` cannot find the nested module
imports used by some OpenTelemetry packages since version 0.56 and higher.
See [#5618](https://github.com/open-telemetry/opentelemetry-js/issues/5618)
Either upgrade to a newer version of Jest to resolve the issue, or use this
workaround for older versions of Jest by adding a `moduleNameMapper` rule.
Add this line to your `jest.config.js`:
``` javascript
module.exports = {
moduleNameMapper: {
'^@opentelemetry/([^/]+)/(.+)$': '<rootDir>/node_modules/@opentelemetry/$1/build/src/index-$2',
}
}
```