Skip to content

Commit

Permalink
feat: add ssr.test.ts
Browse files Browse the repository at this point in the history
This adds a new test to verify that renderHook can be called in an
SSR-like environment based on the changes implemented in testing-library#607.
  • Loading branch information
Joe committed Feb 27, 2022
1 parent 5247d27 commit 93d927d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/__tests__/ssr.test.ts
@@ -0,0 +1,18 @@
/**
* @jest-environment node
*/
import { useState } from 'react'

// This verifies that renderHook can be called in
// a SSR-like environment.
describe('renderHook', () => {
function useLoading() {
const [loading, setLoading] = useState(false)
return { loading, setLoading }
}
runForRenderers(['server'], ({ renderHook }) => {
test('should not throw in SSR environment', () => {
expect(() => renderHook(() => useLoading())).not.toThrowError('document is not defined')
})
})
})

0 comments on commit 93d927d

Please sign in to comment.