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
jonaskinnvall committed Nov 6, 2022
1 parent 8fdc5dc commit 236b99d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/server/__tests__/ssr.test.ts
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')
})
})

0 comments on commit 236b99d

Please sign in to comment.