Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest unexpected token error #146

Open
eerwin-foreflight opened this issue Nov 12, 2024 · 1 comment
Open

Jest unexpected token error #146

eerwin-foreflight opened this issue Nov 12, 2024 · 1 comment

Comments

@eerwin-foreflight
Copy link

Hello!

I am using version 5.1.2 and jest version 26.6.3. When using pdf-merger-js/browser, I was getting an error of "Jest encountered an unexpected token. This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript." when running my jest tests even after properly mocking.

I was eventually able to get around this by adding 'pdf-merger-js': '<rootDir>/node_modules/pdf-merger-js/browser.d.ts', to the moduleNameMapper section in my jest config file.

Also when mocking, I had to do jest.mock('pdf-merger-js') instead of jest.mock('pdf-merger-js/browser') which was a bit confusing.

Just wanted to see if this was expected. I saw no other mentions of having other people having this issue

@mojoaxel
Copy link
Collaborator

Sorry, but I don't have time to look into this at the moment.

I hope in the future we can get one implementation for node and the browser to reduce confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants