Skip to content

Commit

Permalink
Add tests for server component HMR (#43779)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
shuding committed Dec 6, 2022
1 parent fe0315a commit 18d41a9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/e2e/app-dir/index.test.ts
Expand Up @@ -378,6 +378,27 @@ describe('app dir', () => {
}
)
;(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 () => {
const filePath = 'app/client-component-route/page.js'
const origContent = await next.readFile(filePath)
Expand Down

0 comments on commit 18d41a9

Please sign in to comment.