Skip to content

Commit 268354a

Browse files
authored
test(react): update playground/react-emotion to tsx and remove playground/tsconfig (#737)
1 parent e2f0c78 commit 268354a

File tree

14 files changed

+21
-63
lines changed

14 files changed

+21
-63
lines changed

playground/react-emotion/__tests__/react.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ test('should update', async () => {
1414
})
1515

1616
test.runIf(isServe)('should hmr', async () => {
17-
editFile('App.jsx', (code) =>
17+
editFile('src/App.tsx', (code) =>
1818
code.replace('Vite + React + @emotion/react', 'Updated'),
1919
)
2020
await expect.poll(() => page.textContent('h1')).toMatch('Hello Updated')
2121

22-
editFile('Counter.jsx', (code) =>
22+
editFile('src/Counter.tsx', (code) =>
2323
code.replace('color: #646cff;', 'color: #d26ac2;'),
2424
)
2525

@@ -43,7 +43,7 @@ test('should update button style', async () => {
4343
expect(await getButtonBorderStyle()).toMatch('2px solid rgb(0, 0, 0)')
4444

4545
if (isServe) {
46-
editFile('Counter.jsx', (code) =>
46+
editFile('src/Counter.tsx', (code) =>
4747
code.replace('border: 2px solid #000', 'border: 4px solid red'),
4848
)
4949

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
<div id="app"></div>
2-
<script type="module">
3-
import React from 'react'
4-
import ReactDOM from 'react-dom/client'
5-
import App from './App.jsx'
6-
7-
ReactDOM.createRoot(document.getElementById('app')).render(
8-
React.createElement(App),
9-
)
10-
</script>
2+
<script type="module" src="./src/main.tsx"></script>

playground/react-emotion/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"devDependencies": {
1919
"@babel/plugin-proposal-pipeline-operator": "^7.27.1",
2020
"@emotion/babel-plugin": "^11.13.5",
21+
"@types/react": "^19.1.10",
22+
"@types/react-dom": "^19.1.7",
2123
"@vitejs/plugin-react": "workspace:*"
2224
},
2325
"babel": {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { useState } from 'react'
22
import _Switch from 'react-switch'
3-
import { Counter, StyledCode } from './Counter'
4-
const Switch = _Switch.default || _Switch
3+
import { Counter, StyledCode } from './Counter.tsx'
4+
5+
const Switch = (_Switch as any).default || _Switch
56

67
function FragmentTest() {
78
const [checked, setChecked] = useState(false)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function Counter() {
1414
<button
1515
css={css`
1616
border: 2px solid #000;
17+
background: orange;
1718
`}
1819
onClick={() => setCount((count) => count + 1)}
1920
>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import ReactDOM from 'react-dom/client'
2-
import App from './App.jsx'
2+
import App from './App.tsx'
33

44
ReactDOM.createRoot(document.getElementById('app')!).render(<App />)

playground/react-emotion/vite.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default defineConfig({
55
server: { port: 8904 /* Should be unique */ },
66
plugins: [
77
react({
8-
jsxImportSource: '@emotion/react',
98
babel: {
109
plugins: ['@emotion/babel-plugin'],
1110
},
@@ -16,4 +15,7 @@ export default defineConfig({
1615
// to make tests faster
1716
minify: false,
1817
},
18+
optimizeDeps: {
19+
include: ['@emotion/styled/base'],
20+
},
1921
})

playground/tsconfig/__tests__/tsconfig.spec.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

playground/tsconfig/index.html

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)