Skip to content

Commit aca743b

Browse files
[docs] Upgrade note with Jest version requirements and workaround for older versions of Jest (#5619)
Co-authored-by: Marc Pichler <[email protected]>
1 parent cfc33f7 commit aca743b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

doc/frequently-asked-questions.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Frequently Asked Questions
2+
3+
This FAQ has bits of advice and workarounds for common problems.
4+
5+
## I'm using Jest and get import errors when I run my test suite
6+
7+
Test suite failures of the form:
8+
9+
``` text
10+
Cannot find module @opentelemetry/foo/bar from @opentelemetry/...
11+
```
12+
13+
but package `@opentelemetry/foo` is installed may occur with Jest < v29.4.
14+
This is because older versions of `jest-resolve` cannot find the nested module
15+
imports used by some OpenTelemetry packages since version 0.56 and higher.
16+
See [#5618](https://github.com/open-telemetry/opentelemetry-js/issues/5618)
17+
18+
Either upgrade to a newer version of Jest to resolve the issue, or use this
19+
workaround for older versions of Jest by adding a `moduleNameMapper` rule.
20+
Add this line to your `jest.config.js`:
21+
22+
``` javascript
23+
module.exports = {
24+
moduleNameMapper: {
25+
'^@opentelemetry/([^/]+)/(.+)$': '<rootDir>/node_modules/@opentelemetry/$1/build/src/index-$2',
26+
}
27+
}
28+
```

0 commit comments

Comments
 (0)