I am getting an error when I import a file for testing.
This is the only line in the file:
import Cart from '../../components/cart/Cart';
This is the error:
TypeError: Cannot read properties of undefined (reading 'default')
27 |
28 | // Form Blocks
> 29 | export { default as CustomerInfo } from './formBlocks/CustomerInfo';
| ^
30 | export { default as Address } from './formBlocks/Address';
Note: CustomerInfo
is not used in the file I am trying to import. If I comment out that line we get the same error on a different line that is also not related to the component I am trying to import.
The error points to an index file for all of the components.
This also happens if I change the import to any of these variations:
import Cart from '../../components/cart/Cart';
import { Cart } from '../../components';
import { Cart } from '../../components/index';
etc
I also get the same error if I try to import a file that doesn't exist
import ThisFileDoesntExist from '../../components/index';
Why is it looking at the index file if I import it directly from the component file?
Is there some extra config I can add to tell Jest not to look at the index file?