Skip to content

Commit 3e154c8

Browse files
authored
test(react): test no refresh transform for non-jsx files (#547)
1 parent d1fe8c2 commit 3e154c8

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

playground/react/App.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { JsxImportRuntime } from './hmr/jsx-import-runtime'
77
import { CountProvider } from './context/CountProvider'
88
import { ContextButton } from './context/ContextButton'
99
import { TestImportAttributes } from './import-attributes/test'
10+
import { TEST_NON_JSX, TestNonJsx } from './non-jsx/test'
1011

1112
function App() {
1213
const [count, setCount] = useState(0)
@@ -47,6 +48,8 @@ function App() {
4748
<JsxImportRuntime />
4849
<Button>button</Button>
4950
<TestImportAttributes />
51+
{TestNonJsx()}
52+
{TEST_NON_JSX()}
5053
</div>
5154
)
5255
}

playground/react/__tests__/react.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,10 @@ if (!isBuild) {
163163
.poll(() => page.textContent('#accordion-root'))
164164
.toMatch('Accordion Root Updated')
165165
})
166+
167+
test('no refresh transform for non-jsx files', async () => {
168+
const res = await page.request.get(viteTestUrl + '/non-jsx/test.ts')
169+
const code = await res.text()
170+
expect(code).not.toContain('$RefreshReg$')
171+
})
166172
}

playground/react/non-jsx/test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const TestNonJsx = () => {
2+
return 'TestNonJsx'
3+
}
4+
5+
export const TEST_NON_JSX = () => {
6+
return 'TEST_NON_JSX'
7+
}

0 commit comments

Comments
 (0)