diff --git a/packages/react/src/ErrorBoundaryGroup.spec.tsx b/packages/react/src/ErrorBoundaryGroup.spec.tsx
index eb0a91b0b..9d0e8c015 100644
--- a/packages/react/src/ErrorBoundaryGroup.spec.tsx
+++ b/packages/react/src/ErrorBoundaryGroup.spec.tsx
@@ -13,6 +13,8 @@ const innerErrorBoundaryCount = 3
const resetButtonText = 'reset button'
describe('', () => {
+ beforeEach(() => Throw.reset())
+
it('should reset all ErrorBoundaries in children', async () => {
render(
@@ -31,7 +33,6 @@ describe('', () => {
expect(screen.getAllByText(TEXT).length).toBe(innerErrorBoundaryCount)
await waitFor(() => expect(screen.getAllByText(ERROR_MESSAGE).length).toBe(innerErrorBoundaryCount))
- Throw.reset()
fireEvent.click(screen.getByRole('button', { name: resetButtonText }))
expect(screen.getAllByText(TEXT).length).toBe(innerErrorBoundaryCount)
@@ -58,7 +59,6 @@ describe('', () => {
expect(screen.getAllByText(TEXT).length).toBe(innerErrorBoundaryCount)
await waitFor(() => expect(screen.getAllByText(ERROR_MESSAGE).length).toBe(innerErrorBoundaryCount))
- Throw.reset()
fireEvent.click(screen.getByRole('button', { name: resetButtonText }))
expect(screen.getAllByText(TEXT).length).toBe(innerErrorBoundaryCount - 1)
@@ -67,7 +67,21 @@ describe('', () => {
})
describe('useErrorBoundaryGroup', () => {
- it('should throw error without ErrorBoundaryGroup in parent', () => {
+ it('should guarantee hook calling position is in children of ErrorBoundaryGroup', () => {
+ expect(
+ render(
+
+ {createElement(() => {
+ useErrorBoundaryGroup()
+ return <>>
+ })}
+
+ <>{TEXT}>
+
+
+ ).getByText(TEXT)
+ ).toBeInTheDocument()
+
expect(() =>
render(
createElement(() => {
@@ -76,6 +90,7 @@ describe('useErrorBoundaryGroup', () => {
})
)
).toThrow(Message_useErrorBoundaryGroup_this_hook_should_be_called_in_ErrorBoundary_props_children)
+
try {
render(
createElement(() => {