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
Joe committed Feb 26, 2022
1 parent 877f6e8 commit 278101a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/server/__tests__/ssr.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @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 278101a

Please sign in to comment.