Skip to content

Commit 93d927d

Browse files
author
Joe
committed
feat: add ssr.test.ts
This adds a new test to verify that renderHook can be called in an SSR-like environment based on the changes implemented in #607.
1 parent 5247d27 commit 93d927d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/__tests__/ssr.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @jest-environment node
3+
*/
4+
import { useState } from 'react'
5+
6+
// This verifies that renderHook can be called in
7+
// a SSR-like environment.
8+
describe('renderHook', () => {
9+
function useLoading() {
10+
const [loading, setLoading] = useState(false)
11+
return { loading, setLoading }
12+
}
13+
runForRenderers(['server'], ({ renderHook }) => {
14+
test('should not throw in SSR environment', () => {
15+
expect(() => renderHook(() => useLoading())).not.toThrowError('document is not defined')
16+
})
17+
})
18+
})

0 commit comments

Comments
 (0)