Skip to content

Commit

Permalink
fix test case and added spyon console error (#383)
Browse files Browse the repository at this point in the history
* fix test case and added spyon console error

* Update code

---------

Co-authored-by: Arkadii Yakovets <[email protected]>
  • Loading branch information
abhayymishraa and arkid15r authored Jan 9, 2025
1 parent ca4bf97 commit 3c350b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/__tests__/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jest.mock('pages', () => ({
CommitteeDetailsPage: () => <div data-testid="committeedetails-page">CommitteeDetails Page</div>,
ProjectDetailsPage: () => <div data-testid="projectdetails-page">ProjectDetails Page</div>,
UserDetailsPage: () => <div data-testid="userdetails-page">UserDetails Page</div>,
UsersPage: () => <div data-testid="users-page">Users Page</div>,
}))
jest.mock('lib/hooks/useToast', () => ({
useToast: jest.fn(() => ({
Expand Down
8 changes: 8 additions & 0 deletions frontend/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ import '@testing-library/jest-dom'
import { TextEncoder } from 'util'
import dotenv from 'dotenv'
import React from 'react'

dotenv.config()

global.React = React
global.TextEncoder = TextEncoder

beforeEach(() => {
jest.spyOn(console, 'error').mockImplementation((...args) => {
throw new Error(`Console error: ${args.join(' ')}`)
})

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
Expand All @@ -20,4 +27,5 @@ beforeEach(() => {
})),
})
})

jest.mock('@algolia/autocomplete-theme-classic', () => ({}))

0 comments on commit 3c350b0

Please sign in to comment.