Skip to content

Commit

Permalink
feat: add ssr test to repro testing-library#605
Browse files Browse the repository at this point in the history
  • Loading branch information
jfet97 committed Dec 26, 2022
1 parent fe19e69 commit c9a6d5a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/server/__tests__/ssr.test.ts
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',
)
})
})

0 comments on commit c9a6d5a

Please sign in to comment.