Created
July 17, 2021 04:07
-
-
Save brandonchinn178/60a0fb62ebb1988ddbb523c3dcf0c134 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Repro for https://github.com/styled-components/babel-plugin-styled-components/issues/343 | |
1. `mkdir repro && cd repro` | |
1. Copy these files into directory | |
1. `yarn set version berry` | |
1. `yarn` | |
1. `yarn jest`: runs with `babel-jest`, works | |
1. `USE_TS_JEST=1 yarn jest`: runs with `ts-jest`, fails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
presets: [ | |
'@babel/preset-env', | |
[ | |
'@babel/preset-react', | |
{ runtime: 'automatic', development: true } | |
], | |
], | |
plugins: ['babel-plugin-styled-components'], | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render } from '@testing-library/react' | |
import styled from 'styled-components' | |
const MyStyle = styled.div` | |
color: red; | |
` | |
const MyComponent = () => ( | |
<MyStyle>Hello world</MyStyle> | |
) | |
it('foo', () => { | |
const {container} = render(<MyComponent />) | |
expect(container).toMatchInlineSnapshot(` | |
<div> | |
<div | |
class="footest__MyStyle-sc-19fiuzj-0 jpjcxe" | |
> | |
Hello world | |
</div> | |
</div> | |
`) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useTsJest = !!process.env.USE_TS_JEST | |
module.exports = { | |
testEnvironment: 'jsdom', | |
transform: { | |
"\\.tsx$": useTsJest ? "ts-jest" : "babel-jest", | |
}, | |
globals: { | |
'ts-jest': { | |
babelConfig: true | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "foo", | |
"dependencies": { | |
"@babel/core": "^7.14.6", | |
"@babel/preset-env": "^7.14.7", | |
"@babel/preset-react": "^7.14.5", | |
"@testing-library/react": "^12.0.0", | |
"@types/jest": "^26.0.24", | |
"babel-jest": "^27.0.6", | |
"babel-plugin-styled-components": "^1.13.2", | |
"jest": "^27.0.6", | |
"react": "^17.0.2", | |
"react-dom": "^17.0.2", | |
"react-is": "^17.0.2", | |
"styled-components": "^5.3.0", | |
"ts-jest": "^27.0.3", | |
"typescript": "^4.3.5" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"jsx": "preserve", | |
"esModuleInterop": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment