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
Stephen Kilbourn
committed
Nov 15, 2022
1 parent
489496c
commit ba21513
Showing
2 changed files
with
20,851 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,22 @@ | ||
/** | ||
* @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', | ||
) | ||
}) | ||
}) |
Oops, something went wrong.