forked from testing-library/react-hooks-testing-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ssr test to repro testing-library#605
- Loading branch information
1 parent
8fdc5dc
commit 236b99d
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
import { useState } from 'react' | ||
import { renderHook, act } from '..' | ||
|
||
// This verifies that renderHook can be called in | ||
// a SSR-like environment. | ||
describe('renderHook', () => { | ||
function useLoading() { | ||
if (typeof window !== undefined) { | ||
const [loading, setLoading] = useState(false) | ||
return { loading, setLoading } | ||
} | ||
} | ||
test('should not throw in SSR environment', () => { | ||
expect(() => renderHook(() => useLoading())).not.toThrowError('document is not defined') | ||
}) | ||
}) |