question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use styled-engine-sc with jest and npm

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Hello.

I just migrated to material ui v5. I’m using it with styled components.

Everything is OK when I start my app with craco and webpack with the alias config.

Now, i’m trying to launch my jest tests, but I have the engine problem (Module not found: Can’t resolve ‘@emotion/react’ ) npm run test scripts:{ "test": "craco test }

As jest is not launched with webpack, the styled engine configuration is not applied.

What is the solution to use jest, mui with styled components, and npm ?

Thanks

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
FlorianBurgevincommented, Jun 1, 2022

Hi @mnajdova

I succeed to launch my tests by adding a similar configuration for jest in my craco.config.js

jest: {
    configure: (jestConfig) => {
        jestConfig.moduleNameMapper = { "@mui/styled-engine": "<rootDir>/node_modules/@mui/styled-engine-sc" };

        return jestConfig;
    }
}

It is not optimal but it works.

0reactions
mnajdovacommented, Jun 3, 2022

Great, ok it’s good to have it as a reference for other people hitting the same problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

create-react-app-with-styled-components fails with Can't ...
I have noticed two issues with CRA+npm: styled-engine-sc doesn't get installed when using the release tag, need to change it:.
Read more >
Material-UI v5 not working styled-components and typescript?
The mui installation says you can use emotion OR styled-components ... "npm:@mui/styled-engine-sc@latest", "@types/styled-components": ...
Read more >
@mui/styled-engine-sc - npm
styled () API wrapper package for styled-components.. Latest version: 5.11.0, last published: 13 days ago. Start using @mui/styled-engine-sc ...
Read more >
FAQs - styled-components
In general, always use the css helper when composing styling partials to be interpolated into a styled component.. import styled, { keyframes } ......
Read more >
@mui/styled-engine - Material UI
Using styled -components as an engine at this moment is not working when used in a SSR projects. The reason is that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found