traceloop / jest-opentelemetry

Easily run integration tests for your backends

Home Page:https://www.traceloop.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› Bug Report: SyntaxError: Cannot use import statement outside a module

arimus opened this issue Β· comments

πŸ“œ Description

It appears that jest can not properly interpret the index.js file, since it is using imports and is not in commonjs format unlike the compiled TS portions of the code base.

πŸ‘Ÿ Reproduction steps

Use jest to run *.js files instead of using ts-jest, etc. Useful, because there are some challenges with ts-jest and we can run tests on *.js after TS files are compiled down to commonjs.

πŸ‘ Expected behavior

It should not have a syntax error when parsing.

πŸ‘Ž Actual Behavior with Screenshots

@appbloks/storage:test: ● Test suite failed to run
@appbloks/storage:test:
@appbloks/storage:test: test/node_modules/.pnpm/@traceloop+jest-environment-otel@0.8.0/node_modules/@traceloop/jest-environment-otel/index.js:1
@appbloks/storage:test: import { teardown, setup } from './dist/global';
@appbloks/storage:test: ^^^^^^
@appbloks/storage:test:
@appbloks/storage:test: SyntaxError: Cannot use import statement outside a module

πŸ€– Node Version

v18.10.0

πŸ“ƒ Provide any additional context for the Bug.

No response

πŸ‘€ Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

None

FYI, looks like this issue is related to issue #34. I was able to convert the remainder to typescript locally and rebuild and had no issues importing the environment after that.