Unverified Commit 18d41a90 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Add tests for server component HMR (#43779)

Something we haven't covered in our tests.

NEX-35

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent fe0315ab
...@@ -378,6 +378,27 @@ describe('app dir', () => { ...@@ -378,6 +378,27 @@ describe('app dir', () => {
} }
) )
;(isDev ? describe : describe.skip)('HMR', () => { ;(isDev ? describe : describe.skip)('HMR', () => {
it('should HMR correctly for server component', async () => {
const filePath = 'app/dashboard/index/page.js'
const origContent = await next.readFile(filePath)
try {
const browser = await webdriver(next.url, '/dashboard/index')
expect(await browser.elementByCss('p').text()).toContain(
'hello from app/dashboard/index'
)
await next.patchFile(
filePath,
origContent.replace('hello from', 'swapped from')
)
await check(() => browser.elementByCss('p').text(), /swapped from/)
} finally {
await next.patchFile(filePath, origContent)
}
})
it('should HMR correctly for client component', async () => { it('should HMR correctly for client component', async () => {
const filePath = 'app/client-component-route/page.js' const filePath = 'app/client-component-route/page.js'
const origContent = await next.readFile(filePath) const origContent = await next.readFile(filePath)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment