Skip to content

Commit

Permalink
Remove console output validation from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
langdal committed Feb 6, 2025
1 parent fb5b799 commit 0b7470a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { afterEach, describe, expect, it } from 'vitest'
import { ApiProvider } from '@core/context/experiment/api-provider'
import { render, renderHook, screen } from '@testing-library/react'
import { FC } from 'react'
Expand All @@ -19,11 +19,9 @@ const ExperimentWrapper: FC<{ children: React.ReactNode }> = ({ children }) => (

describe('useExperiment', () => {
it('fails if called outside provider', async () => {
console.error = vi.fn()
expect(() => renderHook(() => useExperiment())).toThrow(
'useExperiment must be used within an ExperimentProvider'
)
expect(console.error).toHaveBeenCalled()
})

it('provides context when called inside provider', async () => {
Expand Down
4 changes: 1 addition & 3 deletions sample-app/src/context/global/global-context.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it, vi } from 'vitest'
import { describe, expect, it } from 'vitest'
import { renderHook } from '@testing-library/react'
import { FC } from 'react'
import { State } from '@sample/context/global'
Expand All @@ -14,11 +14,9 @@ const GlobalWrapper: FC<{ children: React.ReactNode }> = ({ children }) => (

describe('useGlobal', () => {
it('fails if called outside provider', async () => {
console.error = vi.fn()
expect(() => renderHook(() => useGlobal())).toThrow(
'useGlobal must be used within a GlobalStateProvider'
)
expect(console.error).toHaveBeenCalled()
})

it('provides context when called inside provider', async () => {
Expand Down

0 comments on commit 0b7470a

Please sign in to comment.