[Bug]: Cannot use with lit-element due to ESM errors, even with transformIgnorePatterns
See original GitHub issueVersion
27.0.6
Steps to reproduce
- Clone my minimal reproducible repo: https://github.com/cdrini/lit-jest-babel-test
- Run
npm install
- Run
npx jest
Expected behavior
I expect to see the tests run
Actual behavior
The test is not run with this error:
Details:
C:\...\lit-jest-babel-test\node_modules\lit-element\lit-element.js:57
import { render } from 'lit-html/lib/shady-render.js';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Despite the fact that this is file should be babel-ed by my jest.config.js
Additional context
No response
Environment
System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Binaries:
Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.17.3 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.7 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: ^27.0.6 => 27.0.6
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Jest throwing error, "transformIgnorePatterns is not working"
When I run my test I am getting the following error. ○ Test suite failed to run Jest encountered an unexpected token This...
Read more >ts-jest syntaxerror: unexpected token 'export'
I know the problem is that the library imports es6 modules and jest does not understand them. Any idea how to make them...
Read more >Jest Unexpected Token a.k.a. won't transpile error - home/pierce
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...
Read more >MIGRATION.md - Storybook
For example, if you're in a webpack5 project but still use Storybook's default webpack4 builder, ... Error: Cannot find module 'react-dom/package.json'.
Read more >How I Fixed The Unexpected Token Error In Jest
I recently ran into a nasty problem that took the better part of a day to get straight. So I'm gonna... Tagged with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Gaaaah, I finally figured it out! Huge thanks to @austinkelleher and https://github.com/facebook/jest/issues/6229#issuecomment-403539460 .
The issue was my .babelrc needed to be renamed to babel.config.js 😖 . Is there any way we could maybe surface this as a warning on https://jestjs.io/docs/ecmascript-modules ? Cause otherwise the fix was really simple and logical; just add lit-element/lit-html to the list of ignored transforms.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.