Skip to content

Commit

Permalink
fix: test configuration and unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakbar-deriv committed Jan 8, 2025
1 parent a6baf3e commit 34db244
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/__tests__/ProtectedRoute.test.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, vi } from 'vitest'
import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import { MemoryRouter } from 'react-router-dom'
import ProtectedRoute from '../ProtectedRoute'
Expand Down
18 changes: 17 additions & 1 deletion src/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import '@testing-library/jest-dom'
import { expect, afterEach } from 'vitest'
import { expect, afterEach, vi } from 'vitest'
import { cleanup } from '@testing-library/react'
import * as matchers from '@testing-library/jest-dom/matchers'
import React from 'react'

// Extend Vitest's expect method with methods from react-testing-library
expect.extend(matchers as any)

// Mock @deriv-com/quill-ui components
vi.mock('@deriv-com/quill-ui', () => {
const React = require('react')
const Skeleton = {
Square: ({ width, height }: { width: string, height: string }) =>
React.createElement('div', { style: { width, height } }, null)
}
return {
Spinner: () => null,
ThemeProvider: ({ children }: { children: React.ReactNode }) => React.createElement(React.Fragment, null, children),
SnackbarProvider: ({ children }: { children: React.ReactNode }) => React.createElement(React.Fragment, null, children),
Skeleton
}
})

// Cleanup after each test case (e.g. clearing jsdom)
afterEach(() => {
cleanup()
Expand Down

0 comments on commit 34db244

Please sign in to comment.