Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/(root)/dashboard/error.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// app/(root)/dashboard/error.test.tsx
import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import DashboardError from './error';

function makeError(message: string): Error {
const e = new Error(message);
return e;
}

describe('DashboardError', () => {
it('shows ⏳ for a rate-limit error', () => {
render(<DashboardError error={makeError('API limit reached')} reset={() => {}} />);
expect(screen.getByText('⏳')).toBeInTheDocument();

Check failure on line 14 in app/(root)/dashboard/error.test.tsx

View workflow job for this annotation

GitHub Actions / Format · Lint · Typecheck · Test

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement>'.
});

it('shows 🕵️‍♂️ for a not-found error', () => {
render(<DashboardError error={makeError('User not found')} reset={() => {}} />);
expect(screen.getByText('🕵️‍♂️')).toBeInTheDocument();

Check failure on line 19 in app/(root)/dashboard/error.test.tsx

View workflow job for this annotation

GitHub Actions / Format · Lint · Typecheck · Test

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement>'.
});

it('shows ⚠️ for a generic error', () => {
render(<DashboardError error={makeError('Unexpected failure')} reset={() => {}} />);
expect(screen.getByText('⚠️')).toBeInTheDocument();

Check failure on line 24 in app/(root)/dashboard/error.test.tsx

View workflow job for this annotation

GitHub Actions / Format · Lint · Typecheck · Test

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement>'.
});
});
1 change: 1 addition & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default defineConfig({
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./vitest.setup.ts'],
include: ['**/*.test.ts', '**/*.test.tsx'],
exclude: ['node_modules', '.next'],
coverage: {
Expand Down
2 changes: 2 additions & 0 deletions vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// vitest.setup.ts
import '@testing-library/jest-dom/vitest';
Loading