Closed hbinkle closed 2 years ago
Please always try to share a repro case in a runnable form - either by providing a git repository to clone or a codesandbox. OSS maintainers usually can't afford the time to set up the repro, even if exact steps are given.
My gut says this has to do with your Jest config and how you are transforming your source code so it can run in Jest. So yes, as Andarist said, we need a minimal repro project.
@Andarist, @srmagura , thanks your reply.
I also assume a setting in the tsconfig. But I can't find out which.
test-demo.zip
I reduced my project down to that one test only.
Simply unzip --> npm i
--> npm run test
Maybe you get an idea why this works when using clsx
but not for cx
in ReconFrame:36
I just found the issue.
The moduleNameMapper
in my jest.config.js
causes it:
moduleNameMapper: {
'^.+.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
},
As soon as I remove that one the test run fine.
created an issue at: https://github.com/eddyerburgh/jest-transform-stub/issues/29
Current behavior: building/running code using
cx
on webpack devserver is fine. But when running simple unit tests using jest I get the error:Uncaught [TypeError: (0 , _css.cx) is not a function]
To reproduce: a unit test like
where MyComponent looks like:
... causes:
Expected behavior: like when webpack builds the project, unit tests should also not throw compile errors.
Environment information: npm: '8.5.0', node: '16.14.2',
react
version: 17.0.2@emotion/react
version: 11.8.1@emotion/css
version: 11.7.1